Skip to content

Commit 1ddca25

Browse files
chore: implement schema object
1 parent 65590b5 commit 1ddca25

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

examples/field-messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ setMessagesProvider(new MessageProvider({
1717
'password.min': 'Password must be at least {min} characters for security',
1818
}))
1919

20-
// Create a user validator
21-
const userValidator = v.object().shape({
20+
// Create a user validator using direct schema syntax
21+
const userValidator = v.object({
2222
username: v.string().min(3).max(20).required(),
2323
email: v.string().email().required(),
2424
password: v.string().min(8).required(),

src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ArrayValidatorType } from './array'
2+
import type { Validator } from './base'
23
import type { BinaryValidatorType } from './binary'
34
import type { BlobValidatorType } from './blob'
45
import type { BooleanValidatorType } from './boolean'
@@ -58,7 +59,7 @@ export interface ValidationInstance {
5859
enum: <T extends string | number>(values: readonly T[]) => EnumValidatorType<T>
5960
date: () => DateValidatorType
6061
datetime: () => DatetimeValidatorType
61-
object: <T extends Record<string, any>>() => ObjectValidatorType<T>
62+
object: <T extends Record<string, any>>(schema?: Record<string, Validator<any>>) => ObjectValidatorType<T>
6263
custom: <T>(validationFn: (value: T) => boolean, message: string) => CustomValidatorType<T>
6364
timestamp: () => TimestampValidatorType
6465
timestampTz: () => TimestampTzValidatorType

0 commit comments

Comments
 (0)