UNPKG

validity-equal-field

Version:

Validity style validator to ensure a property is equal to another schemata field

17 lines (10 loc) 322 B
module.exports = function (field, customMessage) { function validate(key, keyDisplayName, object, cb) { if (object[key] !== object[field]) { var message = customMessage || keyDisplayName + ' must equal ' + field return cb(null, message) } return cb(null, undefined) } return validate }