Skip to main content

Class: ObjectValidator<T>

Type parameters

NameType
Textends NonNullObject

Hierarchy

Constructors

constructor

new ObjectValidator<T>(shape, strategy?, constraints?)

Type parameters

NameType
Textends NonNullObject

Parameters

NameTypeDefault value
shapeMappedObjectValidator<T>undefined
strategyObjectValidatorStrategyObjectValidatorStrategy.Ignore
constraintsreadonly IConstraint<T, T>[][]

Overrides

BaseValidator.constructor

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:23

Properties

constraints

Protected constraints: readonly IConstraint<T, T>[] = []

Inherited from

BaseValidator.constraints

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:11


handleStrategy

Private Readonly handleStrategy: (value: NonNullObject) => Result<T, CombinedPropertyError>

Type declaration

▸ (value): Result<T, CombinedPropertyError>

Parameters
NameType
valueNonNullObject
Returns

Result<T, CombinedPropertyError>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:18


keys

Private Readonly keys: readonly keyof T[] = []

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:17


possiblyUndefinedKeys

Private Readonly possiblyUndefinedKeys: Map<keyof T, BaseValidator<unknown>>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:21


requiredKeys

Private Readonly requiredKeys: Map<keyof T, BaseValidator<unknown>>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:20


shape

Readonly shape: MappedObjectValidator<T>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:15


strategy

Readonly strategy: ObjectValidatorStrategy

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:16

Accessors

array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.array

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:29


ignore

get ignore(): this

Returns

this

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:81


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:21


nullish

get nullish(): UnionValidator<undefined | null | T>

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:25


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:17


partial

get partial(): ObjectValidator<{ [Key in string | number | symbol]?: T[Key] }>

Returns

ObjectValidator<{ [Key in string | number | symbol]?: T[Key] }>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:89


passthrough

get passthrough(): this

Returns

this

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:85


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:33


strict

get strict(): ObjectValidator<{ [Key in string | number | symbol]-?: T[Key] }>

Returns

ObjectValidator<{ [Key in string | number | symbol]-?: T[Key] }>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:77

Methods

addConstraint

Protected addConstraint(constraint): ObjectValidator<T>

Parameters

NameType
constraintIConstraint<T, T>

Returns

ObjectValidator<T>

Inherited from

BaseValidator.addConstraint

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:73


clone

Protected clone(): ObjectValidator<T>

Returns

ObjectValidator<T>

Overrides

BaseValidator.clone

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:126


default

default(value): DefaultValidator<Exclude<T, undefined>>

Parameters

NameType
valueExclude<T, undefined> | () => Exclude<T, undefined>

Returns

DefaultValidator<Exclude<T, undefined>>

Inherited from

BaseValidator.default

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:47


extend

extend<ET>(schema): ObjectValidator<T & ET>

Type parameters

NameType
ETextends NonNullObject

Parameters

NameType
schemaObjectValidator<ET> | MappedObjectValidator<ET>

Returns

ObjectValidator<T & ET>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:94


handle

Protected handle(value): Result<T, CombinedPropertyError | ValidationError>

Parameters

NameType
valueunknown

Returns

Result<T, CombinedPropertyError | ValidationError>

Overrides

BaseValidator.handle

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:109


handleIgnoreStrategy

Private handleIgnoreStrategy(value): Result<T, CombinedPropertyError>

Parameters

NameType
valueNonNullObject

Returns

Result<T, CombinedPropertyError>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:130


handlePassthroughStrategy

Private handlePassthroughStrategy(value): Result<T, CombinedPropertyError>

Parameters

NameType
valueNonNullObject

Returns

Result<T, CombinedPropertyError>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:233


handleStrictStrategy

Private handleStrictStrategy(value): Result<T, CombinedPropertyError>

Parameters

NameType
valueNonNullObject

Returns

Result<T, CombinedPropertyError>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:186


omit

omit<K>(keys): ObjectValidator<{ [Key in string | number | symbol]: T[Key] }>

Type parameters

NameType
Kextends string | number | symbol

Parameters

NameType
keysreadonly K[]

Returns

ObjectValidator<{ [Key in string | number | symbol]: T[Key] }>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:104


or

or<O>(...predicates): UnionValidator<T | O>

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T | O>

Inherited from

BaseValidator.or

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:37


parse

parse(value): T

Parameters

NameType
valueunknown

Returns

T

Inherited from

BaseValidator.parse

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:63


pick

pick<K>(keys): ObjectValidator<{ [Key in string | number | symbol]: T[Key] }>

Type parameters

NameType
Kextends string | number | symbol

Parameters

NameType
keysreadonly K[]

Returns

ObjectValidator<{ [Key in string | number | symbol]: T[Key] }>

Defined in

projects/shapeshift/src/validators/ObjectValidator.ts:99


run

run(value): Result<T, BaseError>

Parameters

NameType
valueunknown

Returns

Result<T, BaseError>

Inherited from

BaseValidator.run

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:51


transform

transform(cb): ObjectValidator<T>

Parameters

NameType
cb(value: T) => T

Returns

ObjectValidator<T>

Inherited from

BaseValidator.transform

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:41

transform<O>(cb): BaseValidator<O>

Type parameters

Name
O

Parameters

NameType
cb(value: T) => O

Returns

BaseValidator<O>

Inherited from

BaseValidator.transform

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:42