Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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;
}
}
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;
}
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) {
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;
}
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;
};
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;
};