Welcome to safe data with Guardian
I’m very excited to introduce the Guardian library as part of the Metro UI project. The library is designed for data validation according to a pre-built scheme. Although the library is positioned as part of Metro UI, it can be used separately from Metro UI.
When used with Metro UI, Guardian is available in the globalThis.G
namespace.
Usage Example
Checkin one guardian
Checking with a lot of guardians
Checking object data
Parsers
- -
G.parse()
- Parsing with throw exception - -
G.safeParse()
- Parsing without exception
Pipes
-
G.pipe()
- pipe with check left to right -
G.compose()
- pipe with check right to left
Available Guardians
- array
- base64
- between
- bigint
- boolean
- bytes
- creditCard (visa, mastercard, discover, jbc, diners, unionPay, americanExpress)
- date
- digits
- domain
- empty
- endsWith
- finite
- float
- func
- hexColor
- imei
- instance
- integer
- ip (ipv4, ipv6)
- length
- maxValue
- minValue
- notNull
- notNumber
- number
- pattern
- promise
- required
- safeInteger
- startsWith
- string
- symbol
- unknown
- url