Class: VObject<Type, Fields, IsOptional, FieldPaths>
values.VObject
The type of the v.object() validator.
Type parameters
| Name | Type |
|---|---|
Type | Type |
Fields | extends Record<string, GenericValidator> |
IsOptional | extends OptionalProperty = "required" |
FieldPaths | extends string = { [Property in keyof Fields]: JoinFieldPaths<Property & string, Fields[Property]["fieldPaths"]> | Property }[keyof Fields] & string |
Hierarchy
-
BaseValidator<Type,IsOptional,FieldPaths>↳
VObject
Constructors
constructor
• new VObject<Type, Fields, IsOptional, FieldPaths>(«destructured»)
Usually you'd use v.object({ ... }) instead.
Type parameters
| Name | Type |
|---|---|
Type | Type |
Fields | extends Record<string, GenericValidator> |
IsOptional | extends OptionalProperty = "required" |
FieldPaths | extends string = { [Property in string | number | symbol]: Property | `${Property & string}.${Fields[Property]["fieldPaths"]}` }[keyof Fields] & string |
Parameters
| Name | Type |
|---|---|
«destructured» | Object |
› isOptional | IsOptional |
› fields | Fields |
Overrides
BaseValidator<Type, IsOptional, FieldPaths>.constructor
Defined in
Properties
type
• Readonly type: Type
Only for TypeScript, the TS type of the JS values validated by this validator.
Inherited from
BaseValidator.type
Defined in
fieldPaths
• Readonly fieldPaths: FieldPaths
Only for TypeScript, if this an Object validator, then this is the TS type of its property names.
Inherited from
BaseValidator.fieldPaths
Defined in
isOptional
• Readonly isOptional: IsOptional
Whether this is an optional Object property value validator.
Inherited from
BaseValidator.isOptional
Defined in
isConvexValidator
• Readonly isConvexValidator: true
Always "true".
Inherited from
BaseValidator.isConvexValidator
Defined in
fields
• Readonly fields: Fields
An object with the validator for each property.
Defined in
kind
• Readonly kind: "object"
The kind of validator, "object".
Defined in
Methods
omit
▸ omit<K>(...fields): VObject<Expand<Omit<Type, K>>, Expand<Omit<Fields, K>>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Omit<Fields, K>>[Property]["fieldPaths"]}` }[keyof Expand<Omit<Fields, K>>] & string>
Create a new VObject with the specified fields omitted.
Type parameters
| Name | Type |
|---|---|
K | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
...fields | K[] | The field names to omit from this VObject. |
Returns
VObject<Expand<Omit<Type, K>>, Expand<Omit<Fields, K>>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Omit<Fields, K>>[Property]["fieldPaths"]}` }[keyof Expand<Omit<Fields, K>>] & string>
Defined in
pick
▸ pick<K>(...fields): VObject<Expand<Pick<Type, Extract<keyof Type, K>>>, Expand<Pick<Fields, K>>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Pick<Fields, K>>[Property]["fieldPaths"]}` }[keyof Expand<Pick<Fields, K>>] & string>
Create a new VObject with only the specified fields.
Type parameters
| Name | Type |
|---|---|
K | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
...fields | K[] | The field names to pick from this VObject. |
Returns
VObject<Expand<Pick<Type, Extract<keyof Type, K>>>, Expand<Pick<Fields, K>>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Pick<Fields, K>>[Property]["fieldPaths"]}` }[keyof Expand<Pick<Fields, K>>] & string>
Defined in
partial
▸ partial(): VObject<{ [K in string | number | symbol]?: Type[K] }, { [K in string | number | symbol]: VOptional<Fields[K]> }, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${{ [K in string | number | symbol]: VOptional<Fields[K]> }[Property]["fieldPaths"]}` }[keyof Fields] & string>
Create a new VObject with all fields marked as optional.
Returns
VObject<{ [K in string | number | symbol]?: Type[K] }, { [K in string | number | symbol]: VOptional<Fields[K]> }, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${{ [K in string | number | symbol]: VOptional<Fields[K]> }[Property]["fieldPaths"]}` }[keyof Fields] & string>
Defined in
extend
▸ extend<NewFields>(fields): VObject<Expand<Type & ObjectType<NewFields>>, Expand<Fields & NewFields>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Fields & NewFields>[Property]["fieldPaths"]}` }[keyof Expand<Fields & NewFields>] & string>
Create a new VObject with additional fields merged in.
Type parameters
| Name | Type |
|---|---|
NewFields | extends Record<string, GenericValidator> |
Parameters
| Name | Type | Description |
|---|---|---|
fields | NewFields | An object with additional validators to merge into this VObject. |
Returns
VObject<Expand<Type & ObjectType<NewFields>>, Expand<Fields & NewFields>, IsOptional, { [Property in string | number | symbol]: Property | `${Property & string}.${Expand<Fields & NewFields>[Property]["fieldPaths"]}` }[keyof Expand<Fields & NewFields>] & string>