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

Properties

constraints

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

Defined in

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


isValidationEnabled

Protected isValidationEnabled: null | boolean | () => boolean = null

Defined in

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

Accessors

array

get array(): ArrayValidator<T[], T>

Returns

ArrayValidator<T[], T>

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Defined in

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


shouldRunConstraints

Protected get shouldRunConstraints(): boolean

Returns

boolean

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): BaseValidator<T>

Parameters

NameType
constraintIConstraint<T, T>

Returns

BaseValidator<T>

Defined in

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


clone

Protected clone(): BaseValidator<T>

Returns

BaseValidator<T>

Defined in

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


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


getValidationEnabled

getValidationEnabled(): null | boolean

Returns

null | boolean

Defined in

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


handle

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

Parameters

NameType
valueunknown

Returns

Result<T, ValidatorError>

Defined in

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


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


parse

parse<R>(value): R

Type parameters

NameType
RT

Parameters

NameType
valueunknown

Returns

R

Defined in

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


run

run(value): Result<T, BaseError>

Parameters

NameType
valueunknown

Returns

Result<T, BaseError>

Defined in

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


setValidationEnabled

setValidationEnabled(isValidationEnabled): BaseValidator<T>

Parameters

NameTypeDescription
isValidationEnablednull | boolean | () => boolean

Returns

BaseValidator<T>

Defined in

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


transform

transform(cb): BaseValidator<T>

Parameters

NameType
cb(value: T) => T

Returns

BaseValidator<T>

Defined in

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

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