How to use aurelia-validation - 10 common examples

To help you get started, we’ve selected a few aurelia-validation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jbockle / aurelia-json-schema-form / dist / es2015 / rules / string-rules.js View on Github external
add() {
        // format datetime
        // tslint:disable-next-line:max-line-length
        const iso8601Datetime = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i;
        ValidationRules
            .customRule('format_datetime', (val) => !!val ? iso8601Datetime.test(val) : true, this.configuration.messages.format_datetime || '${$displayName} is not a valid date/time.');
        // format date
        const iso8601Date = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
        ValidationRules
            .customRule('format_date', (val) => !!val ? iso8601Date.test(val) : true, this.configuration.messages.format_date || '${$displayName} is not a valid date.');
        // format time
        const iso8601Time = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i;
        ValidationRules
            .customRule('format_time', (val) => !!val ? iso8601Time.test(val) : true, this.configuration.messages.format_time || '${$displayName} is not a valid time.');
        // format ipv4
        const ipv4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
        ValidationRules
            .customRule('format_ipv4', (val) => !!val ? ipv4.test(val) : true, this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.');
        // format ipv6
        // tslint:disable-next-line:max-line-length
        const ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
github jbockle / aurelia-json-schema-form / dist / es2015 / rules / string-rules.js View on Github external
.customRule('format_ipv4', (val) => !!val ? ipv4.test(val) : true, this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.');
        // format ipv6
        // tslint:disable-next-line:max-line-length
        const ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
        ValidationRules
            .customRule('format_ipv6', (val) => !!val ? ipv6.test(val) : true, this.configuration.messages.format_ipv6 || '${$displayName} is not a valid IPv6 address.');
        // format hostname
        const hostname = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
        ValidationRules
            .customRule('format_hostname', (val) => !!val ? hostname.test(val) : true, this.configuration.messages.format_hostname || '${$displayName} is not a valid hostname.');
        // format uri
        const uri = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
        ValidationRules
            .customRule('format_uri', (val) => !!val ? uri.test(val) : true, this.configuration.messages.format_uri || '${$displayName} is not a valid URI.');
        // pattern
        ValidationRules
            .customRule('pattern', (val, _obj, pattern) => !!val ? (new RegExp(pattern)).test(val) : true, this.configuration.messages.pattern || '${$displayName} is not correctly formatted.', (pattern) => ({ pattern }));
    }
    bind(ctrl, rule) {
github jbockle / aurelia-json-schema-form / src / aurelia-json-schema-form / rules / string-rules.ts View on Github external
this.configuration.messages.format_time || '${$displayName} is not a valid time.'
      );

    // format ipv4
    const ipv4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
    ValidationRules
      .customRule(
        'format_ipv4',
        (val: string) => !!val ? ipv4.test(val) : true,
        this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.'
      );

    // format ipv6
    // tslint:disable-next-line:max-line-length
    const ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
    ValidationRules
      .customRule(
        'format_ipv6',
        (val: string) => !!val ? ipv6.test(val) : true,
        this.configuration.messages.format_ipv6 || '${$displayName} is not a valid IPv6 address.'
      );

    // format hostname
    const hostname = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
    ValidationRules
      .customRule(
        'format_hostname',
        (val: string) => !!val ? hostname.test(val) : true,
        this.configuration.messages.format_hostname || '${$displayName} is not a valid hostname.'
      );

    // format uri
github jbockle / aurelia-json-schema-form / dist / es2015 / rules / string-rules.js View on Github external
// format ipv4
        const ipv4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
        ValidationRules
            .customRule('format_ipv4', (val) => !!val ? ipv4.test(val) : true, this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.');
        // format ipv6
        // tslint:disable-next-line:max-line-length
        const ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
        ValidationRules
            .customRule('format_ipv6', (val) => !!val ? ipv6.test(val) : true, this.configuration.messages.format_ipv6 || '${$displayName} is not a valid IPv6 address.');
        // format hostname
        const hostname = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
        ValidationRules
            .customRule('format_hostname', (val) => !!val ? hostname.test(val) : true, this.configuration.messages.format_hostname || '${$displayName} is not a valid hostname.');
        // format uri
        const uri = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
        ValidationRules
            .customRule('format_uri', (val) => !!val ? uri.test(val) : true, this.configuration.messages.format_uri || '${$displayName} is not a valid URI.');
        // pattern
        ValidationRules
            .customRule('pattern', (val, _obj, pattern) => !!val ? (new RegExp(pattern)).test(val) : true, this.configuration.messages.pattern || '${$displayName} is not correctly formatted.', (pattern) => ({ pattern }));
    }
    bind(ctrl, rule) {
github jbockle / aurelia-json-schema-form / src / aurelia-json-schema-form / rules / string-rules.ts View on Github external
(val: string) => !!val ? ipv6.test(val) : true,
        this.configuration.messages.format_ipv6 || '${$displayName} is not a valid IPv6 address.'
      );

    // format hostname
    const hostname = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
    ValidationRules
      .customRule(
        'format_hostname',
        (val: string) => !!val ? hostname.test(val) : true,
        this.configuration.messages.format_hostname || '${$displayName} is not a valid hostname.'
      );

    // format uri
    const uri = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
    ValidationRules
      .customRule(
        'format_uri',
        (val: string) => !!val ? uri.test(val) : true,
        this.configuration.messages.format_uri || '${$displayName} is not a valid URI.'
      );

    // pattern
    ValidationRules
      .customRule(
        'pattern',
        (val, _obj, pattern) => !!val ? (new RegExp(pattern)).test(val) : true,
        this.configuration.messages.pattern || '${$displayName} is not correctly formatted.',
        (pattern) => ({ pattern })
      );
  }
github process-engine / bpmn-studio / src / modules / solution-explorer / solution-explorer-solution / solution-explorer-solution.ts View on Github external
private setValidationRules(): void {
    ValidationRules.ensure((state: IDiagramNameInputState) => state.currentDiagramInputValue)
      .required()
      .withMessage('Diagram name cannot be blank.')
      .satisfies((input: string) => {
        const inputIsNotEmpty: boolean = input !== undefined;

        const inputAsCharArray: Array = inputIsNotEmpty ? input.split('') : [];

        const diagramNamePassesNameChecks: boolean = inputAsCharArray.every((letter: string) => {
          // tslint:disable-next-line:typedef
          const letterMatches = (regExp: RegExp): boolean => regExp.test(letter);

          return this.diagramValidationRegExpList.some(letterMatches);
        });

        return diagramNamePassesNameChecks;
      })
github jbockle / aurelia-json-schema-form / dist / commonjs / rules / string-rules.js View on Github external
.customRule('format_ipv4', function (val) { return !!val ? ipv4.test(val) : true; }, this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.');
        // format ipv6
        // tslint:disable-next-line:max-line-length
        var ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
        aurelia_validation_1.ValidationRules
            .customRule('format_ipv6', function (val) { return !!val ? ipv6.test(val) : true; }, this.configuration.messages.format_ipv6 || '${$displayName} is not a valid IPv6 address.');
        // format hostname
        var hostname = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
        aurelia_validation_1.ValidationRules
            .customRule('format_hostname', function (val) { return !!val ? hostname.test(val) : true; }, this.configuration.messages.format_hostname || '${$displayName} is not a valid hostname.');
        // format uri
        var uri = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
        aurelia_validation_1.ValidationRules
            .customRule('format_uri', function (val) { return !!val ? uri.test(val) : true; }, this.configuration.messages.format_uri || '${$displayName} is not a valid URI.');
        // pattern
        aurelia_validation_1.ValidationRules
            .customRule('pattern', function (val, _obj, pattern) { return !!val ? (new RegExp(pattern)).test(val) : true; }, this.configuration.messages.pattern || '${$displayName} is not correctly formatted.', function (pattern) { return ({ pattern: pattern }); });
    };
    StringRules.prototype.bind = function (ctrl, rule) {
github jbockle / aurelia-json-schema-form / dist / commonjs / rules / string-rules.js View on Github external
StringRules.prototype.add = function () {
        // format datetime
        // tslint:disable-next-line:max-line-length
        var iso8601Datetime = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i;
        aurelia_validation_1.ValidationRules
            .customRule('format_datetime', function (val) { return !!val ? iso8601Datetime.test(val) : true; }, this.configuration.messages.format_datetime || '${$displayName} is not a valid date/time.');
        // format date
        var iso8601Date = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
        aurelia_validation_1.ValidationRules
            .customRule('format_date', function (val) { return !!val ? iso8601Date.test(val) : true; }, this.configuration.messages.format_date || '${$displayName} is not a valid date.');
        // format time
        var iso8601Time = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i;
        aurelia_validation_1.ValidationRules
            .customRule('format_time', function (val) { return !!val ? iso8601Time.test(val) : true; }, this.configuration.messages.format_time || '${$displayName} is not a valid time.');
        // format ipv4
        var ipv4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
        aurelia_validation_1.ValidationRules
            .customRule('format_ipv4', function (val) { return !!val ? ipv4.test(val) : true; }, this.configuration.messages.format_ipv4 || '${$displayName} is not a valid IPv4 address.');
        // format ipv6
        // tslint:disable-next-line:max-line-length
        var ipv6 = /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i;
github jbockle / aurelia-json-schema-form / dist / es2015 / rules / number-rules.js View on Github external
add() {
        // minimum
        ValidationRules
            .customRule('minimum', (val, _obj, min) => val !== undefined ? val >= min : true, this.configuration.messages.minimum || '${$displayName} must be greater than or equal to ${$config.min}.', (min) => ({ min }));
        // exclusionMinimum
        ValidationRules
            .customRule('exclusiveMinimum', (val, _obj, min) => val !== undefined ? val > min : true, this.configuration.messages.exclusiveMinimum || '${$displayName} must be greater than ${$config.min}.', (min) => ({ min }));
        // maximum
        ValidationRules
            .customRule('maximum', (val, _obj, max) => val !== undefined ? val <= max : true, this.configuration.messages.maximum || '${$displayName} must be less than or equal to ${$config.max}.', (max) => ({ max }));
        // exclusiveMaximum
        ValidationRules
            .customRule('exclusiveMaximum', (val, _obj, max) => val !== undefined ? val < max : true, this.configuration.messages.exclusiveMaximum || '${$displayName} must be less than ${$config.max}.', (max) => ({ max }));
        // multipleOf
        ValidationRules
            .customRule('multipleOf', (val, _obj, multiple) => val !== undefined ? ((val % multiple) / 100) === 0 : true, this.configuration.messages.multipleOf || '${$displayName} must be a multiple of ${$config.multiple}.', (multiple) => ({ multiple }));
    }
    bind(ctrl, rule) {
github jbockle / aurelia-json-schema-form / src / aurelia-json-schema-form / rules / number-rules.ts View on Github external
add() {
    // minimum
    ValidationRules
      .customRule(
        'minimum',
        (val, _obj, min) => val !== undefined ? val >= min : true,
        this.configuration.messages.minimum || '${$displayName} must be greater than or equal to ${$config.min}.',
        (min) => ({ min })
      );

    // exclusionMinimum
    ValidationRules
      .customRule(
        'exclusiveMinimum',
        (val, _obj, min) => val !== undefined ? val > min : true,
        this.configuration.messages.exclusiveMinimum || '${$displayName} must be greater than ${$config.min}.',
        (min) => ({ min })
      );