Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test(type, ...args) {
const cache = this.get('_testValidatorCache');
const unsupportedTypes = ['alias', 'belongs-to', 'dependent', 'has-many'];
if (unsupportedTypes.includes(type)) {
throw new Error(
`[ember-cp-validations] The \`test\` API does not support validators of type: ${type}.`
);
}
cache[type] = cache[type] || lookupValidator(getOwner(this), type).create();
const result = cache[type].validate(...args);
if (isPromise(result)) {
return result.then(r => new TestResult(r), r => new TestResult(r));
}
return new TestResult(result);
}
});