Allow spaces
Alias for startsWith
Require string to have a length between min and max
Alias for custom
Add a custom function to test the value with
import yxc from "@dotvirus/yxc"
yxc.string().test()
Check if string is an email
Check ending of a string
import yxc from "@dotvirus/yxc"
yxc.string().endsWith("pusher").validate("test") // -> Fails
yxc.string().endsWith("pusher").validate("Squarepusher") // -> OK
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
Alias for length
Test string length
Alias for regex
Limit string length
Require minimum string length
Require string to have at least 1 character
Allows null value
Fails if string contains non-number (0-9) values
Allows undefined value
Alias for regex
Alias for startsWith
Check a regex
Alias for custom
Check beginning of a string
import yxc from "@dotvirus/yxc"
yxc.string().startsWith("pusher").validate("Squarepusher") // -> Fails
yxc.string().startsWith("Squ").validate("Squarepusher") // -> OK
Alias for endsWith
Alias for custom
Alias for custom
Validate a value Returns a IValidationResult array
import yxc from "@dotvirus/yxc"
yxc.string().validate(myValue)
Generated using TypeDoc
Only allow alphanumeric values