Closed zeke closed 3 years ago
This PR updates the documentation for the conform function to clarify that it doesn't specifically require a true or false return value. Any truthy or falsy value will also validate.
conform
true
false
Example:
const revalidator = require('revalidator') const schema1 = { properties: { name: { conform: function (input) { return input } } } } const schema2 = { properties: { name: { conform: function (input) { return null } } } } const obj = { name: 'jane' } console.log(revalidator.validate(obj, schema1)) // { valid: true, errors: [] } console.log(revalidator.validate(obj, schema2)) // { // valid: false, // errors: [ // { // attribute: 'conform', // property: 'name', // expected: [Function: conform], // actual: 'jane', // message: 'must conform to given constraint' // } // ] // }
This PR updates the documentation for the
conform
function to clarify that it doesn't specifically require atrue
orfalse
return value. Any truthy or falsy value will also validate.Example: