Skip to main content

Class: NumberValidator<T>

Type parameters

NameType
Textends number

Hierarchy

Constructors

constructor

new NumberValidator<T>(constraints?)

Type parameters

NameType
Textends number

Parameters

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

Inherited from

BaseValidator.constructor

Defined in

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

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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

Accessors

abs

get abs(): this

Returns

this

Defined in

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


array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.array

Defined in

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


ceil

get ceil(): this

Returns

this

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:97


finite

get finite(): this

Returns

this

Defined in

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


floor

get floor(): this

Returns

this

Defined in

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


fround

get fround(): this

Returns

this

Defined in

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


int

get int(): this

Returns

this

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:49


negative

get negative(): this

Returns

this

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:65


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


positive

get positive(): this

Returns

this

Defined in

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


round

get round(): this

Returns

this

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:93


safeInt

get safeInt(): this

Returns

this

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:53


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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


sign

get sign(): this

Returns

this

Defined in

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


trunc

get trunc(): this

Returns

this

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): NumberValidator<T>

Parameters

NameType
constraintIConstraint<T, T>

Returns

NumberValidator<T>

Inherited from

BaseValidator.addConstraint

Defined in

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


clone

Protected clone(): NumberValidator<T>

Returns

NumberValidator<T>

Inherited from

BaseValidator.clone

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

Inherited from

BaseValidator.default

Defined in

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


divisibleBy

divisibleBy(divider): NumberValidator<T>

Parameters

NameType
dividernumber

Returns

NumberValidator<T>

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:69


equal

equal<N>(number): NumberValidator<N>

Type parameters

NameType
Nextends number

Parameters

NameType
numberN

Returns

NumberValidator<N>

Defined in

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


greaterThan

greaterThan(number): NumberValidator<T>

Parameters

NameType
numbernumber

Returns

NumberValidator<T>

Defined in

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


greaterThanOrEqual

greaterThanOrEqual(number): NumberValidator<T>

Parameters

NameType
numbernumber

Returns

NumberValidator<T>

Defined in

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


handle

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

Parameters

NameType
valueunknown

Returns

Result<T, ValidationError>

Overrides

BaseValidator.handle

Defined in

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


lessThan

lessThan(number): NumberValidator<T>

Parameters

NameType
numbernumber

Returns

NumberValidator<T>

Defined in

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


lessThanOrEqual

lessThanOrEqual(number): NumberValidator<T>

Parameters

NameType
numbernumber

Returns

NumberValidator<T>

Defined in

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


notEqual

notEqual(number): NumberValidator<T>

Parameters

NameType
numbernumber

Returns

NumberValidator<T>

Defined in

projects/shapeshift/src/validators/NumberValidator.ts:43


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


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

Parameters

NameType
cb(value: T) => T

Returns

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