Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (key, value, _oldValue, changes, content) => {
if (target && (changes[target] || (changes[target] === undefined && content[target]))) {
if ((changes[target] === targetValue) || (changes[target] === undefined && (content[target] === targetValue))) {
return true;
}
}
const result = validate('presence', value, options, null, key);
if (typeof result === 'boolean' || typeof result === 'string') {
return result;
}
// We flipped the meaning behind `present` and `blank` so switch the two
if (result.type === 'present') {
result.type = 'blank';
} else if (result.type === 'blank') {
result.type = 'present';
}
return buildMessage(key, result);
};
}
return (key, value, _oldValue, changes, content) => {
if (targets && !targets.some((target) => changes[target] || (changes[target] === undefined && content[target]))) {
return true;
}
let result = validate('presence', value, options, null, key);
if (typeof result === 'boolean' || typeof result === 'string') {
return result;
} else {
// We flipped the meaning behind `present` and `blank` so switch the two
if (result.type === 'present') {
result.type = 'blank';
} else if (result.type === 'blank') {
result.type = 'present';
}
return buildMessage(key, result);
}
};
}
return (key, newValue, _oldValue, changes/*, _content*/) => {
let result = validate('confirmation', newValue, options, changes, key);
return (result === true) ? true : buildMessage(key, result);
};
}
validate() {
let result = _validate(this.get('_evType'), ...arguments);
if (result && typeof result === 'object') {
return result.message
? result.message
: this.createErrorMessage(result.type, result.value, result.context);
}
return result;
}
});
return (key, value) => {
let result = validate('exclusion', value, options, null, key);
return (result === true) ? true : buildMessage(key, result);
};
}
return (key, value) => {
let result = validate('inclusion', value, options, null, key);
return (result === true) ? true : buildMessage(key, result);
};
}
return (key, value) => {
let result = validate('length', value, options, null, key);
return (result === true) ? true : buildMessage(key, result);
};
}
return (key, value) => {
if (!hasOptions) {
return true;
}
let result = validate('format', value, options, null, key);
return (result === true) ? true : buildMessage(key, result);
};
}
return (key, value) => {
let result = validate('number', value, options, null, key);
return (result === true) ? true : buildMessage(key, result);
};
}