File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ pnpm add @stacksjs/ts-validation
42
42
import { v } from ' @stacksjs/ts-validation'
43
43
44
44
// Create a validator for a user object
45
- const userValidator = v .object (). shape ( {
45
+ const userValidator = v .object ({
46
46
name: v .string ().min (2 ).max (50 ).required (),
47
47
email: v .string ().email ().required (),
48
48
age: v .number ().min (18 ).integer ().required (),
@@ -127,14 +127,15 @@ const coordinatesValidator = v.array().length(2).each(v.number()).required()
127
127
128
128
``` typescript
129
129
// Object validation
130
- const addressValidator = v .object (). shape ( {
130
+ const addressValidator = v .object ({
131
131
street: v .string ().required (),
132
132
city: v .string ().required (),
133
133
state: v .string ().length (2 ).required (),
134
134
zip: v .string ().matches (/ ^ \d {5} $ / ).required (),
135
135
})
136
136
137
137
// Nested object validation
138
+ // .shape() is an alias for .object()
138
139
const userValidator = v .object ().shape ({
139
140
name: v .string ().required (),
140
141
address: addressValidator ,
You can’t perform that action at this time.
0 commit comments