src/core/validator.js
function validationFn (validations, {name, args}, field, data, messages, formatter) {
  return new PLazy((resolve, reject) => {
    const camelizedName = snakeToCamelCase(name)
    const validation = validations[camelizedName]

    if (typeof (validation) !== 'function') {
      const error = new Error(`${camelizedName} is not defined as a validation rule`)
      formatter.addError(error, field, camelizedName, args)
      reject(error)
      return
    }

    validation(data, field, getMessage(messages, field, name, args), args, prop)
      .then(resolve)
      .catch((error) => {
        formatter.addError(error, field, camelizedName, args)
        reject(error)
      })
  })
}
function validationFn (validations, {name, args}, field, data, messages, formatter) {
  return new PLazy((resolve, reject) => {
    const camelizedName = snakeToCamelCase(name)
    const validation = validations[camelizedName]

    if (typeof (validation) !== 'function') {
      const error = new Error(`${camelizedName} is not defined as a validation rule`)
      formatter.addError(error, field, camelizedName, args)
      reject(error)
      return
    }

    validation(data, field, getMessage(messages, field, name, args), args, prop)
      .then(resolve)
      .catch((error) => {
        formatter.addError(error, field, camelizedName, args)
        reject(error)
      })
  })
}
function validationFn ( validations , { name , args } , field , data , messages , formatter ) { return new PLazy ( ( resolve , reject ) => { const camelizedName = snakeToCamelCase ( name ) const validation = validations [ camelizedName ] if ( typeof ( validation ) !== 'function' ) { const error = new Error ( ` ${ camelizedName } ` ) formatter . addError ( error , field , camelizedName , args ) reject ( error ) return } validation ( data , field , getMessage ( messages , field , name , args ) , args , prop ) . then ( resolve ) . catch ( ( error ) => { formatter . addError ( error , field , camelizedName , args ) reject ( error ) } ) } ) }
Returns a lazy promise which runs the validation on a field
for a given rule. This method will register promise
rejections with the formatter.

@method validationFn

@param    {Object} validations
@param    {Object} rule
@property {String} rule.name
@property {Array}  rule.args
@param    {String} field
@param    {Object} data
@param    {Object} messages
@param    {Object} formatter

@returns {Promise}
Returns a lazy promise which runs the validation on a field for a given rule . This method will register promise rejections with the formatter .