format
format(callback, [ctx])
Effect
Format the final return value of validate
and validateSilent
, the return value of callback
will be the final return value.
Arguments
callback
(function) - The format function. The function has an argument: the return value returned byvalidate
. The return value ofcallback
is recommended but not necessarily to be the type of the schema declared.[ctx]
(*) - The execution context of callback.
Example
const schema = racoon.number();
schema.validate(1.2).format(num => num.toFixed(2)); // pass, 返回 '1.20'
Last updated
Was this helpful?