validateSilent

validateSilent([value])

Effect

The silent version of validate. validateSilent will not throw any error when validate failed. It will always return the error and value.

Arguments

  • [value] (*) - The value to detect, default is undefined.

Returns

Always return an object as below:

Field

Necessary

Description

error

N

The error object when validating failed. If validate passed, the field isundefined

value

Y

When validating passed, value is the same as the return value ofvalidate.

Otherwise, value is the original detected value.

Example

const schema = racoon.number().min(0);
const { error, value } = schema.validateSilent(2);
if (error) {
  // fail
} else {
  // pass
}

Last updated