index.js
function autoValidate(object) {
  const seq = (object) ? object.seq : undefined;
  const action = (object) ? object.action : undefined;

  const schema = identifySchema(object)

  if (schema) {
    const {error, value} = validate(object, schema);

    if (error) {
      return { isValid: false, seq, action, error };
    } else {
      return { isValid: true, seq, action, value };
    }
  } else {
    return { isValid: false, seq, action,
      error: new Error('No matching schema found.') };
  }
}
function autoValidate(object) {
  const seq = (object) ? object.seq : undefined;
  const action = (object) ? object.action : undefined;

  const schema = identifySchema(object)

  if (schema) {
    const {error, value} = validate(object, schema);

    if (error) {
      return { isValid: false, seq, action, error };
    } else {
      return { isValid: true, seq, action, value };
    }
  } else {
    return { isValid: false, seq, action,
      error: new Error('No matching schema found.') };
  }
}
function autoValidate ( object ) { const seq = ( object ) ? object . seq : undefined ; const action = ( object ) ? object . action : undefined ; const schema = identifySchema ( object ) if ( schema ) { const { error , value } = validate ( object , schema ) ; if ( error ) { return { isValid : false , seq , action , error } ; } else { return { isValid : true , seq , action , value } ; } } else { return { isValid : false , seq , action , error : new Error ( 'No matching schema found.' ) } ; } }
Validate the object, auto-detecting its schema.
Validate the object auto - detecting its schema .