Class: ObjectValidator<T, I>
Type parameters
Name | Type |
---|---|
T | extends object |
I | UndefinedToOptional <T > |
Hierarchy
-
↳
ObjectValidator
Constructors
constructor
• new ObjectValidator<T
, I
>(shape
, strategy?
, constraints?
): ObjectValidator
<T
, I
>
Type parameters
Name | Type |
---|---|
T | extends object |
I | UndefinedToOptional <T > |
Parameters
Name | Type | Default value |
---|---|---|
shape | MappedObjectValidator <T > | undefined |
strategy | ObjectValidatorStrategy | ObjectValidatorStrategy.Ignore |
constraints | readonly IConstraint <I , I >[] | [] |
Returns
ObjectValidator
<T
, I
>
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:25
Properties
constraints
• Protected
constraints: readonly IConstraint
<I
, I
>[] = []
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:17
description
• Optional
description: string
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:15
handleStrategy
• Private
Readonly
handleStrategy: (value
: object
) => Result
<I
, CombinedPropertyError
>
Type declaration
▸ (value
): Result
<I
, CombinedPropertyError
>
Parameters
Name | Type |
---|---|
value | object |
Returns
Result
<I
, CombinedPropertyError
>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:19
isValidationEnabled
• Protected
isValidationEnabled: null
| boolean
| () => boolean
= null
Inherited from
BaseValidator.isValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:18
keys
• Private
Readonly
keys: readonly keyof I
[] = []
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:18
parent
• Protected
Optional
parent: object
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:16
possiblyUndefinedKeys
• Private
Readonly
possiblyUndefinedKeys: Map
<keyof I
, BaseValidator
<unknown
>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:22
possiblyUndefinedKeysWithDefaults
• Private
Readonly
possiblyUndefinedKeysWithDefaults: Map
<keyof I
, DefaultValidator
<unknown
>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:23
requiredKeys
• Private
Readonly
requiredKeys: Map
<keyof I
, BaseValidator
<unknown
>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:21
shape
• Readonly
shape: MappedObjectValidator
<T
>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:16
strategy
• Readonly
strategy: ObjectValidatorStrategy
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:17
Accessors
array
• get
array(): ArrayValidator
<T
[], T
>
Returns
ArrayValidator
<T
[], T
>
Inherited from
BaseValidator.array
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:41
ignore
• get
ignore(): this
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:88
nullable
• get
nullable(): UnionValidator
<null
| T
>
Returns
UnionValidator
<null
| T
>
Inherited from
BaseValidator.nullable
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:33
nullish
• get
nullish(): UnionValidator
<undefined
| null
| T
>
Returns
UnionValidator
<undefined
| null
| T
>
Inherited from
BaseValidator.nullish
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:37
optional
• get
optional(): UnionValidator
<undefined
| T
>
Returns
UnionValidator
<undefined
| T
>
Inherited from
BaseValidator.optional
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:29
partial
• get
partial(): ObjectValidator
<{ [Key in string | number | symbol]?: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]?: I[Key] }>>
Returns
ObjectValidator
<{ [Key in string | number | symbol]?: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]?: I[Key] }>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:96
passthrough
• get
passthrough(): this
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:92
required
• get
required(): ObjectValidator
<{ [Key in string | number | symbol]-?: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]-?: I[Key] }>>
Returns
ObjectValidator
<{ [Key in string | number | symbol]-?: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]-?: I[Key] }>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:101
set
• get
set(): SetValidator
<T
>
Returns
SetValidator
<T
>
Inherited from
BaseValidator.set
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:45
shouldRunConstraints
• get
shouldRunConstraints(): boolean
Returns
boolean
Inherited from
BaseValidator.shouldRunConstraints
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:120
strict
• get
strict(): this
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:84
Methods
addConstraint
▸ addConstraint(constraint
): ObjectValidator
<T
, I
>
Parameters
Name | Type |
---|---|
constraint | IConstraint <I , I > |
Returns
ObjectValidator
<T
, I
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:132
clone
▸ clone(): ObjectValidator
<T
, I
>
Returns
ObjectValidator
<T
, I
>
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:156
default
▸ default(value
): DefaultValidator
<Exclude
<I
, undefined
>>
Parameters
Name | Type |
---|---|
value | Exclude <I , undefined > | () => Exclude <I , undefined > |
Returns
DefaultValidator
<Exclude
<I
, undefined
>>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:65
describe
▸ describe(description
): ObjectValidator
<T
, I
>
Parameters
Name | Type |
---|---|
description | string |
Returns
ObjectValidator
<T
, I
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:73
extend
▸ extend<ET
>(schema
): ObjectValidator
<T
& ET
, UndefinedToOptional
<T
& ET
>>
Type parameters
Name | Type |
---|---|
ET | extends object |
Parameters
Name | Type |
---|---|
schema | ObjectValidator <ET , UndefinedToOptional <ET >> | MappedObjectValidator <ET > |
Returns
ObjectValidator
<T
& ET
, UndefinedToOptional
<T
& ET
>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:112
getValidationEnabled
▸ getValidationEnabled(): null
| boolean
Returns
null
| boolean
Inherited from
BaseValidator.getValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:116
handle
▸ handle(value
): Result
<I
, ValidationError
| CombinedPropertyError
>
Parameters
Name | Type |
---|---|
value | unknown |
Returns
Result
<I
, ValidationError
| CombinedPropertyError
>
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:131
handleIgnoreStrategy
▸ handleIgnoreStrategy(value
): Result
<I
, CombinedPropertyError
>
Parameters
Name | Type |
---|---|
value | object |
Returns
Result
<I
, CombinedPropertyError
>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:160
handlePassthroughStrategy
▸ handlePassthroughStrategy(value
): Result
<I
, CombinedPropertyError
>
Parameters
Name | Type |
---|---|
value | object |
Returns
Result
<I
, CombinedPropertyError
>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:275
handleStrictStrategy
▸ handleStrictStrategy(value
): Result
<I
, CombinedPropertyError
>
Parameters
Name | Type |
---|---|
value | object |
Returns
Result
<I
, CombinedPropertyError
>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:222
is
▸ is<R
>(value
): value is R
Type parameters
Name | Type |
---|---|
R | I |
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is R
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:101
omit
▸ omit<K
>(keys
): ObjectValidator
<{ [Key in string | number | symbol]: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]: I[Key] }>>
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type |
---|---|
keys | readonly K [] |
Returns
ObjectValidator
<{ [Key in string | number | symbol]: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]: I[Key] }>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:124
or
▸ or<O
>(...predicates
): UnionValidator
<I
| O
>
Type parameters
Name |
---|
O |
Parameters
Name | Type |
---|---|
...predicates | readonly BaseValidator <O >[] |
Returns
UnionValidator
<I
| O
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:49
parse
▸ parse<R
>(value
): R
Type parameters
Name | Type |
---|---|
R | I |
Parameters
Name | Type |
---|---|
value | unknown |
Returns
R
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:91
pick
▸ pick<K
>(keys
): ObjectValidator
<{ [Key in string | number | symbol]: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]: I[Key] }>>
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type |
---|---|
keys | readonly K [] |
Returns
ObjectValidator
<{ [Key in string | number | symbol]: I[Key] }, UndefinedToOptional
<{ [Key in string | number | symbol]: I[Key] }>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:117
reshape
▸ reshape(cb
): ObjectValidator
<T
, I
>
Parameters
Name | Type |
---|---|
cb | (input : I ) => Result <I , Error > |
Returns
ObjectValidator
<T
, I
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:59
▸ reshape<R
, O
>(cb
): BaseValidator
<O
>
Type parameters
Name | Type |
---|---|
R | extends Result <unknown , Error > |
O | InferResultType <R > |
Parameters
Name | Type |
---|---|
cb | (input : I ) => R |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:60
run
▸ run(value
): Result
<I
, BaseError
>
Parameters
Name | Type |
---|---|
value | unknown |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:79
setParent
▸ setParent(parent
): ObjectValidator
<T
, I
>
Parameters
Name | Type |
---|---|
parent | object |
Returns
ObjectValidator
<T
, I
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:24
setValidationEnabled
▸ setValidationEnabled(isValidationEnabled
): ObjectValidator
<T
, I
>
Sets if the validator should also run constraints or just do basic checks.
Parameters
Name | Type | Description |
---|---|---|
isValidationEnabled | null | boolean | () => boolean | Whether this validator should be enabled or disabled. You can pass boolean or a function returning boolean which will be called just before parsing. Set to null to go off of the global configuration. |
Returns
ObjectValidator
<T
, I
>
Inherited from
BaseValidator.setValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:110
transform
▸ transform(cb
): ObjectValidator
<T
, I
>
Parameters
Name | Type |
---|---|
cb | (value : I ) => I |
Returns
ObjectValidator
<T
, I
>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:53
▸ transform<O
>(cb
): BaseValidator
<O
>
Type parameters
Name |
---|
O |
Parameters
Name | Type |
---|---|
cb | (value : I ) => O |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:54
when
▸ when<Key
, This
>(key
, options
): ObjectValidator
<T
, I
>
Type parameters
Name | Type |
---|---|
Key | extends WhenKey |
This | extends BaseValidator <any > = ObjectValidator <T , I > |
Parameters
Name | Type |
---|---|
key | Key |
options | WhenOptions <This , Key > |
Returns
ObjectValidator
<T
, I
>