Skip to main content

Class: BaseValidator<T>

Type parameters

Name
T

Hierarchy

Constructors

constructor

new BaseValidator<T>(constraints?)

Type parameters

Name
T

Parameters

NameTypeDefault value
constraintsreadonly IConstraint<T, T>[][]

Defined in

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

Properties

constraints

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

Defined in

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

Accessors

array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): BaseValidator<T>

Parameters

NameType
constraintIConstraint<T, T>

Returns

BaseValidator<T>

Defined in

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


clone

Protected clone(): BaseValidator<T>

Returns

BaseValidator<T>

Defined in

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


default

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

Parameters

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

Returns

DefaultValidator<Exclude<T, undefined>>

Defined in

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


handle

Protected Abstract handle(value): Result<T, ValidatorError>

Parameters

NameType
valueunknown

Returns

Result<T, ValidatorError>

Defined in

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


or

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

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T | O>

Defined in

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


parse

parse(value): T

Parameters

NameType
valueunknown

Returns

T

Defined in

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


run

run(value): Result<T, BaseError>

Parameters

NameType
valueunknown

Returns

Result<T, BaseError>

Defined in

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


transform

transform(cb): BaseValidator<T>

Parameters

NameType
cb(value: T) => T

Returns

BaseValidator<T>

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>

Defined in

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