Gathering detailed insights and metrics for @olton/guardian
Gathering detailed insights and metrics for @olton/guardian
Gathering detailed insights and metrics for @olton/guardian
Gathering detailed insights and metrics for @olton/guardian
npm install @olton/guardian
Typescript
Module System
Node Version
NPM Version
65.9
Supply Chain
97.6
Quality
84.8
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
200%
3
Compared to previous day
Last week
-20%
12
Compared to previous week
Last month
47.3%
137
Compared to previous month
Last year
0%
1,006
Compared to previous year
1
5
Data guard and validation library. Validate user input with Guardian.
1npm i @olton/guardian
1import {parse, string, required, email, object} from "@olton/guardian" 2 3const schema = string() 4let value = parse(schema, "123") 5 6console.log(value); // -> 123 7 8let value = parse(schema, 123) // -> throw error 9 10 11let value = safeParse(schema, 123) // -> return obj with error 12if (!value.ok) { 13 console.log(value.error) 14} 15 16let value = safeParse(schema, "123") // -> return obj with data 17if (value.ok) { 18 console.log(value.output) 19} 20 21let schema = object({ 22 name: pipe(required("Name Required"), string()), 23 email: pipe(string(), email("Please enter a valid email address")) 24}) 25 26const res0 = parse(schema, { 27 name: "Vasya Pupkin", 28 email: "vasya@pupkin.com" 29}) // -> Ok 30 31const res1 = parse(schema, { 32 name: "", 33 email: "vasya@pupkin.com" 34}) // -> Error "Name Required" 35 36const res2 = parse(schema, { 37 name: "Serhii Pimenov", 38 email: "vasya_pupkin.com" 39}) // -> Error "Please enter a valid email address" 40 41
1import {pipe, string, email} from "@olton/guardian" 2 3const scheme1 = pipe(string(), email()) // left to right 4const scheme2 = compose(email(), string()) // right to left
1import {parse, object, visa, mastercard, string, email} from "@olton/guardian" 2 3const schema1 = string() 4const data1 = parse(schema1, "123") 5 6const schema2 = pipe(required(), email()) 7const data2 = parse(schema2, "vasya@pupkin.com")
1import {parse, object, visa, mastercard, string, email} from "@olton/guardian" 2 3const schema = object({ 4 name: string(), 5 email: email(), 6 cards: object({ 7 visa: visa(), 8 mastercard: mastercard() 9 }) 10}) 11 12const data = parse(schema, {...})
No vulnerabilities found.
No security vulnerabilities found.