Skip to main content

keyof()

keyof<T>(objectSchema, message?): KeyofSchema<ObjectSchema<T>>

Keyof schema - validates that the value is a key of an object.


Type Parametersโ€‹

T: T extends Record<string, GenericSchema>โ€‹


Parametersโ€‹

objectSchema: ObjectSchema<T> | ObjectConstraint<T> | { entries: T; }โ€‹

Object schema whose keys to validate.

message?: stringโ€‹

Custom error message.


Returns: KeyofSchema<ObjectSchema<T>>โ€‹

Schema that validates the object keys.


Sinceโ€‹

2.0.0