Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function validatePresence(value, options, model, attribute) {
let { presence, ignoreBlank } = getProperties(options, ['presence', 'ignoreBlank']);
let v = unwrapProxy(value);
let _isPresent = ignoreBlank ? isPresent(v) : !isEmpty(v);
assert(`[validator:presence] [${attribute}] option 'presence' is required`, isPresent(presence));
if (presence === true && !_isPresent) {
return validationError('blank', value, options);
}
if (presence === false && _isPresent) {
return validationError('present', value, options);
}
return true;
}