Skip to main content

Class: ObjectValidator<T, I>

Type parameters

NameType
Textends NonNullObject
IUndefinedToOptional<T>

Hierarchy

Constructors

constructor

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

Type parameters

NameType
Textends NonNullObject
IUndefinedToOptional<T>

Parameters

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

Overrides

BaseValidator.constructor

Defined in

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

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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


handleStrategy

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

Type declaration

▸ (value): Result<I, CombinedPropertyError>

Parameters
NameType
valueNonNullObject
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:15


keys

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

Defined in

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


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:33


ignore

get ignore(): this

Returns

this

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

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


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:95


passthrough

get passthrough(): this

Returns

this

Defined in

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


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:100


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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


shouldRunConstraints

Protected get shouldRunConstraints(): boolean

Returns

boolean

Inherited from

BaseValidator.shouldRunConstraints

Defined in

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


strict

get strict(): this

Returns

this

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): ObjectValidator<T, I>

Parameters

NameType
constraintIConstraint<I, I>

Returns

ObjectValidator<T, I>

Inherited from

BaseValidator.addConstraint

Defined in

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


clone

Protected clone(): ObjectValidator<T, I>

Returns

ObjectValidator<T, I>

Overrides

BaseValidator.clone

Defined in

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


default

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

Parameters

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

Returns

DefaultValidator<Exclude<I, undefined>>

Inherited from

BaseValidator.default

Defined in

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


extend

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

Type parameters

NameType
ETextends NonNullObject

Parameters

NameType
schemaObjectValidator<ET, UndefinedToOptional<ET>> | MappedObjectValidator<ET>

Returns

ObjectValidator<T & ET, UndefinedToOptional<T & ET>>

Defined in

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


getValidationEnabled

getValidationEnabled(): null | boolean

Returns

null | boolean

Inherited from

BaseValidator.getValidationEnabled

Defined in

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


handle

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

Parameters

NameType
valueunknown

Returns

Result<I, CombinedPropertyError | ValidationError>

Overrides

BaseValidator.handle

Defined in

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


handleIgnoreStrategy

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

Parameters

NameType
valueNonNullObject

Returns

Result<I, CombinedPropertyError>

Defined in

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


handlePassthroughStrategy

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

Parameters

NameType
valueNonNullObject

Returns

Result<I, CombinedPropertyError>

Defined in

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


handleStrictStrategy

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

Parameters

NameType
valueNonNullObject

Returns

Result<I, CombinedPropertyError>

Defined in

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


omit

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

Type parameters

NameType
Kextends string | number | symbol

Parameters

NameType
keysreadonly 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:123


or

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

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<I | O>

Inherited from

BaseValidator.or

Defined in

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


parse

parse<R>(value): R

Type parameters

NameType
RI

Parameters

NameType
valueunknown

Returns

R

Inherited from

BaseValidator.parse

Defined in

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


pick

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

Type parameters

NameType
Kextends string | number | symbol

Parameters

NameType
keysreadonly 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:116


reshape

reshape(cb): ObjectValidator<T, I>

Parameters

NameType
cb(input: I) => Result<I, Error>

Returns

ObjectValidator<T, I>

Inherited from

BaseValidator.reshape

Defined in

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

reshape<R, O>(cb): BaseValidator<O>

Type parameters

NameType
Rextends Result<unknown, Error, R>
OInferResultType<R>

Parameters

NameType
cb(input: I) => R

Returns

BaseValidator<O>

Inherited from

BaseValidator.reshape

Defined in

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


run

run(value): Result<I, BaseError>

Parameters

NameType
valueunknown

Returns

Result<I, BaseError>

Inherited from

BaseValidator.run

Defined in

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


setValidationEnabled

setValidationEnabled(isValidationEnabled): ObjectValidator<T, I>

Parameters

NameTypeDescription
isValidationEnablednull | boolean | () => boolean

Returns

ObjectValidator<T, I>

Inherited from

BaseValidator.setValidationEnabled

Defined in

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


transform

transform(cb): ObjectValidator<T, I>

Parameters

NameType
cb(value: I) => I

Returns

ObjectValidator<T, I>

Inherited from

BaseValidator.transform

Defined in

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

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

Type parameters

Name
O

Parameters

NameType
cb(value: I) => O

Returns

BaseValidator<O>

Inherited from

BaseValidator.transform

Defined in

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