Class: ObjectValidator<T, I>
Extends
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends object | - |
I | UndefinedToOptional<T> |
Constructors
new ObjectValidator()
new ObjectValidator<
T,I>(shape:MappedObjectValidator<T>,strategy:ObjectValidatorStrategy,validatorOptions:ValidatorOptions,constraints: readonlyIConstraint<I,I>[]):ObjectValidator<T,I>
Parameters
| Parameter | Type | Default value |
|---|---|---|
shape | MappedObjectValidator<T> | undefined |
strategy | ObjectValidatorStrategy | ObjectValidatorStrategy.Ignore |
validatorOptions | ValidatorOptions | {} |
constraints | readonly IConstraint<I, I>[] | [] |
Returns
ObjectValidator<T, I>
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:25
Properties
constraints
protectedconstraints: readonlyIConstraint<I,I>[] =[]
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:19
description?
optionaldescription:string
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:16
isValidationEnabled
protectedisValidationEnabled:null|boolean| () =>boolean=null
Inherited from
BaseValidator.isValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:20
parent?
protectedoptionalparent:object
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:18
shape
readonlyshape:MappedObjectValidator<T>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:16
strategy
readonlystrategy:ObjectValidatorStrategy
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:17
validatorOptions
protectedvalidatorOptions:ValidatorOptions
Inherited from
BaseValidator.validatorOptions
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:17
Accessors
shouldRunConstraints
Get Signature
get
protectedshouldRunConstraints():boolean
Returns
boolean
Inherited from
BaseValidator.shouldRunConstraints
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:143
Methods
addConstraint()
protectedaddConstraint(constraint:IConstraint<I,I>,validatorOptions:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
constraint | IConstraint<I, I> |
validatorOptions | ValidatorOptions |
Returns
this
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:155
array()
array(
options:ValidatorOptions):ArrayValidator<I[],I>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
ArrayValidator<I[], I>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:44
clone()
protectedclone():this
Returns
this
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:172
default()
default(
value:Exclude<I,undefined> | () =>Exclude<I,undefined>,options:ValidatorOptions):DefaultValidator<Exclude<I,undefined>>
Parameters
| Parameter | Type |
|---|---|
value | Exclude<I, undefined> | () => Exclude<I, undefined> |
options | ValidatorOptions |
Returns
DefaultValidator<Exclude<I, undefined>>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:81
describe()
describe(
description:string):this
Parameters
| Parameter | Type |
|---|---|
description | string |
Returns
this
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:96
extend()
extend<
ET>(schema:ObjectValidator<ET,UndefinedToOptional<ET>> |MappedObjectValidator<ET>,options:ValidatorOptions):ObjectValidator<T&ET,UndefinedToOptional<T&ET>>
Type Parameters
| Type Parameter |
|---|
ET extends object |
Parameters
| Parameter | Type |
|---|---|
schema | ObjectValidator<ET, UndefinedToOptional<ET>> | MappedObjectValidator<ET> |
options | ValidatorOptions |
Returns
ObjectValidator<T & ET, UndefinedToOptional<T & ET>>
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:113
getValidationEnabled()
getValidationEnabled():
null|boolean
Returns
null | boolean
Inherited from
BaseValidator.getValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:139
handle()
protectedhandle(value:unknown):Result<I,ValidationError|CombinedPropertyError>
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
Result<I, ValidationError | CombinedPropertyError>
Overrides
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:141
ignore()
ignore(
options:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:89
is()
is<
R>(value:unknown):value is R
Type Parameters
| Type Parameter | Default type |
|---|---|
R | I |
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
value is R
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:124
nullable()
nullable(
options:ValidatorOptions):UnionValidator<null|I>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<null | I>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:36
nullish()
nullish(
options:ValidatorOptions):UnionValidator<undefined|null|I>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<undefined | null | I>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:40
omit()
omit<
K>(keys: readonlyK[],options:ValidatorOptions):ObjectValidator<{ [Key in string | number | symbol]: I[Key] },UndefinedToOptional<{ [Key in string | number | symbol]: I[Key] }>>
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
keys | readonly K[] |
options | ValidatorOptions |
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:131
optional()
optional(
options:ValidatorOptions):UnionValidator<undefined|I>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<undefined | I>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:32
or()
or<
O>(...predicates: readonlyBaseValidator<O>[]):UnionValidator<I|O>
Type Parameters
| Type Parameter |
|---|
O |
Parameters
| Parameter | Type |
|---|---|
...predicates | readonly BaseValidator<O>[] |
Returns
UnionValidator<I | O>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:52
parse()
parse<
R>(value:unknown):R
Type Parameters
| Type Parameter | Default type |
|---|---|
R | I |
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
R
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:114
partial()
partial(
options:ValidatorOptions):ObjectValidator<{ [Key in string | number | symbol]?: I[Key] },UndefinedToOptional<{ [Key in string | number | symbol]?: I[Key] }>>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
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:97
passthrough()
passthrough(
options:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:93
pick()
pick<
K>(keys: readonlyK[],options:ValidatorOptions):ObjectValidator<{ [Key in string | number | symbol]: I[Key] },UndefinedToOptional<{ [Key in string | number | symbol]: I[Key] }>>
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
keys | readonly K[] |
options | ValidatorOptions |
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:121
required()
required(
options:ValidatorOptions):ObjectValidator<{ [Key in string | number | symbol]-?: I[Key] },UndefinedToOptional<{ [Key in string | number | symbol]-?: I[Key] }>>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
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:102
reshape()
reshape(cb, options)
reshape(
cb: (input:I) =>Result<I,Error>,options?:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
cb | (input: I) => Result<I, Error> |
options? | ValidatorOptions |
Returns
this
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:67
reshape(cb, options)
reshape<
R,O>(cb: (input:I) =>R,options?:ValidatorOptions):BaseValidator<O>
Type Parameters
| Type Parameter | Default type |
|---|---|
R extends Result<unknown, Error> | - |
O | InferResultType<R> |
Parameters
| Parameter | Type |
|---|---|
cb | (input: I) => R |
options? | ValidatorOptions |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:68
run()
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:102
set()
set(
options:ValidatorOptions):SetValidator<I>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
SetValidator<I>
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:48
setParent()
setParent(
parent:object):this
Parameters
| Parameter | Type |
|---|---|
parent | object |
Returns
this
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:27
setValidationEnabled()
setValidationEnabled(
isValidationEnabled:null|boolean| () =>boolean):this
Sets if the validator should also run constraints or just do basic checks.
Parameters
| Parameter | 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
this
Inherited from
BaseValidator.setValidationEnabled
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:133
strict()
strict(
options:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/ObjectValidator.ts:85
transform()
transform(cb, options)
transform(
cb: (value:I) =>I,options?:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
cb | (value: I) => I |
options? | ValidatorOptions |
Returns
this
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:56
transform(cb, options)
transform<
O>(cb: (value:I) =>O,options?:ValidatorOptions):BaseValidator<O>
Type Parameters
| Type Parameter |
|---|
O |
Parameters
| Parameter | Type |
|---|---|
cb | (value: I) => O |
options? | ValidatorOptions |
Returns
Inherited from
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:57
when()
when<
Key,This>(key:Key,options:WhenOptions<This,Key>,validatorOptions?:ValidatorOptions):this
Type Parameters
| Type Parameter | Default type |
|---|---|
Key extends WhenKey | - |
This extends BaseValidator<any> | ObjectValidator<T, I> |
Parameters
| Parameter | Type |
|---|---|
key | Key |
options | WhenOptions<This, Key> |
validatorOptions? | ValidatorOptions |
Returns
this