Class: abstract
BaseValidator<T>
Extended by
ArrayValidator
BigIntValidator
BooleanValidator
DateValidator
DefaultValidator
InstanceValidator
LiteralValidator
MapValidator
NativeEnumValidator
NeverValidator
NullishValidator
NumberValidator
ObjectValidator
PassthroughValidator
RecordValidator
SetValidator
StringValidator
TupleValidator
TypedArrayValidator
UnionValidator
Type Parameters
Type Parameter |
---|
T |
Constructors
new BaseValidator()
new BaseValidator<
T
>(validatorOptions
:ValidatorOptions
,constraints
: readonlyIConstraint
<T
,T
>[]):BaseValidator
<T
>
Parameters
Parameter | Type | Default value |
---|---|---|
validatorOptions | ValidatorOptions | {} |
constraints | readonly IConstraint <T , T >[] | [] |
Returns
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:22
Properties
constraints
protected
constraints: readonlyIConstraint
<T
,T
>[] =[]
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:19
description?
optional
description:string
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:16
isValidationEnabled
protected
isValidationEnabled:null
|boolean
| () =>boolean
=null
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:20
parent?
protected
optional
parent:object
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:18
validatorOptions
protected
validatorOptions:ValidatorOptions
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:17
Accessors
shouldRunConstraints
Get Signature
get
protected
shouldRunConstraints():boolean
Returns
boolean
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:143
Methods
addConstraint()
protected
addConstraint(constraint
:IConstraint
<T
,T
>,validatorOptions
:ValidatorOptions
):this
Parameters
Parameter | Type |
---|---|
constraint | IConstraint <T , T > |
validatorOptions | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:155
array()
array(
options
:ValidatorOptions
):ArrayValidator
<T
[],T
>
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
ArrayValidator
<T
[], T
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:44
clone()
protected
clone():this
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:147
default()
default(
value
:Exclude
<T
,undefined
> | () =>Exclude
<T
,undefined
>,options
:ValidatorOptions
):DefaultValidator
<Exclude
<T
,undefined
>>
Parameters
Parameter | Type |
---|---|
value | Exclude <T , undefined > | () => Exclude <T , undefined > |
options | ValidatorOptions |
Returns
DefaultValidator
<Exclude
<T
, undefined
>>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:81
describe()
describe(
description
:string
):this
Parameters
Parameter | Type |
---|---|
description | string |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:96
getValidationEnabled()
getValidationEnabled():
null
|boolean
Returns
null
| boolean
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:139
handle()
abstract
protected
handle(value
:unknown
):Result
<T
,ValidatorError
>
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
Result
<T
, ValidatorError
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:153
is()
is<
R
>(value
:unknown
):value is R
Type Parameters
Type Parameter | Default type |
---|---|
R | T |
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
value is R
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:124
nullable()
nullable(
options
:ValidatorOptions
):UnionValidator
<null
|T
>
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<null
| T
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:36
nullish()
nullish(
options
:ValidatorOptions
):UnionValidator
<undefined
|null
|T
>
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<undefined
| null
| T
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:40
optional()
optional(
options
:ValidatorOptions
):UnionValidator
<undefined
|T
>
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<undefined
| T
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:32
or()
or<
O
>(...predicates
: readonlyBaseValidator
<O
>[]):UnionValidator
<T
|O
>
Type Parameters
Type Parameter |
---|
O |
Parameters
Parameter | Type |
---|---|
...predicates | readonly BaseValidator <O >[] |
Returns
UnionValidator
<T
| O
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:52
parse()
parse<
R
>(value
:unknown
):R
Type Parameters
Type Parameter | Default type |
---|---|
R | T |
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
R
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:114
reshape()
reshape(cb, options)
reshape(
cb
: (input
:T
) =>Result
<T
,Error
>,options
?:ValidatorOptions
):this
Parameters
Parameter | Type |
---|---|
cb | (input : T ) => Result <T , Error > |
options ? | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:67
reshape(cb, options)
reshape<
R
,O
>(cb
: (input
:T
) =>R
,options
?:ValidatorOptions
):BaseValidator
<O
>
Type Parameters
Type Parameter | Default type |
---|---|
R extends Result <unknown , Error > | - |
O | InferResultType <R > |
Parameters
Parameter | Type |
---|---|
cb | (input : T ) => R |
options ? | ValidatorOptions |
Returns
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:68
run()
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:102
set()
set(
options
:ValidatorOptions
):SetValidator
<T
>
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
SetValidator
<T
>
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:48
setParent()
setParent(
parent
:object
):this
Parameters
Parameter | Type |
---|---|
parent | object |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:27
setValidationEnabled()
setValidationEnabled(
isValidationEnabled
:null
|boolean
| () =>boolean
):this
Sets if the validator should also run constraints or just do basic checks.
Parameters
Parameter | Type | Description |
---|---|---|
isValidationEnabled | null | boolean | () => boolean | Whether this validator should be enabled or disabled. You can pass boolean or a function returning boolean which will be called just before parsing. Set to null to go off of the global configuration. |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:133
transform()
transform(cb, options)
transform(
cb
: (value
:T
) =>T
,options
?:ValidatorOptions
):this
Parameters
Parameter | Type |
---|---|
cb | (value : T ) => T |
options ? | ValidatorOptions |
Returns
this
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:56
transform(cb, options)
transform<
O
>(cb
: (value
:T
) =>O
,options
?:ValidatorOptions
):BaseValidator
<O
>
Type Parameters
Type Parameter |
---|
O |
Parameters
Parameter | Type |
---|---|
cb | (value : T ) => O |
options ? | ValidatorOptions |
Returns
Defined in
projects/shapeshift/src/validators/BaseValidator.ts:57
when()
when<
Key
,This
>(key
:Key
,options
:WhenOptions
<This
,Key
>,validatorOptions
?:ValidatorOptions
):this
Type Parameters
Type Parameter | Default type |
---|---|
Key extends WhenKey | - |
This extends BaseValidator <any > | BaseValidator <T > |
Parameters
Parameter | Type |
---|---|
key | Key |
options | WhenOptions <This , Key > |
validatorOptions ? | ValidatorOptions |
Returns
this