Alias for custom
Add a custom function to test the value with
import yxc from "@dotvirus/yxc"
yxc.string().test()
Only allows a selection of values
import yxc from "@dotvirus/yxc"
const allowedValues = ["test", "test2", "test3"]
yxc.string().enum(allowedValues).validate("test") // -> OK
yxc.string().enum(allowedValues).validate("asdasd") // -> Fails
Alias for equals
Alias for equals
Only allows a certain value Value is checked using strict equality (===)
import yxc from "@dotvirus/yxc"
yxc.string().equals("test").validate("test") // -> OK
yxc.string().equals("test").validate("test2") // -> Fails
Only allow falsy values(https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
Allows null value
Allows undefined value
Alias for custom
Alias for custom
Only allow truthy values (https://developer.mozilla.org/en-US/docs/Glossary/Truthy)
Alias for custom
Validate a value Returns a IValidationResult array
import yxc from "@dotvirus/yxc"
yxc.string().validate(myValue)
Generated using TypeDoc
Validate any value, use rules to narrow it down