How to use the aurelia-validation.ValidationError function in aurelia-validation

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 aurelia / validatejs / src / validator.js View on Github external
}
    if (!rules) {
      // no rules defined for propertyName.
      return errors;
    }
    rules = rules.rules;
    for (let i = 0, ii = rules.length; i < ii; i++) {
      const ruleInfo = rules[i];
      if (propertyName !== null && ruleInfo.key !== propertyName) {
        continue;
      }
      const { name, config } = ruleInfo.rule;
      const validator = { [propertyName]: { [name]: config } };
      const result = validate(object, validator);
      if (result) {
        errors.push(new ValidationError(ruleInfo.rule, result[propertyName][0], object, propertyName));
      }
    }
    return errors;
  }
github aurelia / validatejs / dist / aurelia-validatejs.js View on Github external
}
    if (!rules) {
      // no rules defined for propertyName.
      return errors;
    }
    rules = rules.rules;
    for (let i = 0, ii = rules.length; i < ii; i++) {
      const ruleInfo = rules[i];
      if (propertyName !== null && ruleInfo.key !== propertyName) {
        continue;
      }
      const { name, config } = ruleInfo.rule;
      const validator = { [propertyName]: { [name]: config } };
      const result = validate(object, validator);
      if (result) {
        errors.push(new ValidationError(ruleInfo.rule, result[propertyName][0], object, propertyName));
      }
    }
    return errors;
  }
github aurelia / validatejs / dist / es2015 / validation-rule.js View on Github external
validate(target, propName) {
    if (target && propName) {
      let validator = { [propName]: { [this.name]: this.config } };
      let result = validate(target, validator);
      if (result) {
        let error = cleanResult(result);
        result = new ValidationError(error);
      }
      return result;
    }
    throw new Error('Invalid target or property name.');
  }
  static date(config = true) {
github aurelia / validatejs / dist / es2015 / aurelia-validatejs.js View on Github external
rules = metadata.get(metadataKey, object);
    }
    if (!rules) {
      return errors;
    }
    rules = rules.rules;
    for (let i = 0, ii = rules.length; i < ii; i++) {
      const ruleInfo = rules[i];
      if (propertyName !== null && ruleInfo.key !== propertyName) {
        continue;
      }
      const { name, config } = ruleInfo.rule;
      const validator = { [propertyName]: { [name]: config } };
      const result = validate(object, validator);
      if (result) {
        errors.push(new ValidationError(ruleInfo.rule, result[propertyName][0], object, propertyName));
      }
    }
    return errors;
  }
github aurelia / validatejs / dist / commonjs / aurelia-validatejs.js View on Github external
rules = rules.rules;
    for (var i = 0, ii = rules.length; i < ii; i++) {
      var _propertyName, _validator;

      var ruleInfo = rules[i];
      if (propertyName !== null && ruleInfo.key !== propertyName) {
        continue;
      }
      var _ruleInfo$rule = ruleInfo.rule;
      var name = _ruleInfo$rule.name;
      var config = _ruleInfo$rule.config;

      var validator = (_validator = {}, _validator[propertyName] = (_propertyName = {}, _propertyName[name] = config, _propertyName), _validator);
      var result = (0, _validate3.default)(object, validator);
      if (result) {
        errors.push(new _aureliaValidation.ValidationError(ruleInfo.rule, result[propertyName][0], object, propertyName));
      }
    }
    return errors;
  };
github aurelia / validatejs / dist / native-modules / aurelia-validatejs.js View on Github external
rules = rules.rules;
    for (var i = 0, ii = rules.length; i < ii; i++) {
      var _propertyName, _validator;

      var ruleInfo = rules[i];
      if (propertyName !== null && ruleInfo.key !== propertyName) {
        continue;
      }
      var _ruleInfo$rule = ruleInfo.rule;
      var name = _ruleInfo$rule.name;
      var config = _ruleInfo$rule.config;

      var validator = (_validator = {}, _validator[propertyName] = (_propertyName = {}, _propertyName[name] = config, _propertyName), _validator);
      var result = validate(object, validator);
      if (result) {
        errors.push(new ValidationError(ruleInfo.rule, result[propertyName][0], object, propertyName));
      }
    }
    return errors;
  };