Skip to main content

Class: UnionValidator<T>

Type parameters

Name
T

Hierarchy

Constructors

constructor

new UnionValidator<T>(validators, constraints?)

Type parameters

Name
T

Parameters

NameTypeDefault value
validatorsreadonly BaseValidator<T>[]undefined
constraintsreadonly IConstraint<T, T>[][]

Overrides

BaseValidator.constructor

Defined in

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

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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


validators

Private validators: readonly BaseValidator<T>[]

Defined in

projects/shapeshift/src/validators/UnionValidator.ts:9

Accessors

array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.array

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Overrides

BaseValidator.nullable

Defined in

projects/shapeshift/src/validators/UnionValidator.ts:39


nullish

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

Returns

UnionValidator<undefined | null | T>

Overrides

BaseValidator.nullish

Defined in

projects/shapeshift/src/validators/UnionValidator.ts:62


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Overrides

BaseValidator.optional

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): UnionValidator<T>

Parameters

NameType
constraintIConstraint<T, T>

Returns

UnionValidator<T>

Inherited from

BaseValidator.addConstraint

Defined in

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


clone

Protected clone(): UnionValidator<T>

Returns

UnionValidator<T>

Overrides

BaseValidator.clone

Defined in

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


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


handle

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

Parameters

NameType
valueunknown

Returns

Result<T, CombinedError | ValidationError>

Overrides

BaseValidator.handle

Defined in

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


or

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

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T | O>

Overrides

BaseValidator.or

Defined in

projects/shapeshift/src/validators/UnionValidator.ts:79


parse

parse(value): T

Parameters

NameType
valueunknown

Returns

T

Inherited from

BaseValidator.parse

Defined in

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


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): UnionValidator<T>

Parameters

NameType
cb(value: T) => T

Returns

UnionValidator<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