allowString

allowString()

Effect

Allow the detected value to be a string style number.

NOTE

A String that matches the regular expression /^[+-]?\d.?\d$/ is a string style number. Such as '123', '-123', '0.123', '.123'.

Since

>=1.3.0

Arguments

None

Example

const schema1 = racoon.number();
schema.validate('123'); // fail

const schema2 = racoon.number().allowString();
schema.validate('123'); // pass, return 123
schema.validate('.123'); // pass, return 0.123
schema.validate('-123'); // pass, return -123
schema.validate('+123'); // pass, return 123

Last updated