Class: StringValidator<T>
Defined in: projects/shapeshift/src/validators/StringValidator.ts:24
Extends
Type Parameters
Type Parameter |
---|
T extends string |
Constructors
new StringValidator()
new StringValidator<
T
>(validatorOptions
:ValidatorOptions
,constraints
: readonlyIConstraint
<T
,T
>[]):StringValidator
<T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:22
Parameters
Parameter | Type | Default value |
---|---|---|
validatorOptions | ValidatorOptions | {} |
constraints | readonly IConstraint <T , T >[] | [] |
Returns
Inherited from
Properties
constraints
protected
constraints: readonlyIConstraint
<T
,T
>[] =[]
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:19
Inherited from
description?
optional
description:string
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:16
Inherited from
isValidationEnabled
protected
isValidationEnabled:null
|boolean
| () =>boolean
=null
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:20
Inherited from
BaseValidator
.isValidationEnabled
parent?
protected
optional
parent:object
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:18
Inherited from
validatorOptions
protected
validatorOptions:ValidatorOptions
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:17
Inherited from
BaseValidator
.validatorOptions
Accessors
shouldRunConstraints
Get Signature
get
protected
shouldRunConstraints():boolean
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:143
Returns
boolean
Inherited from
BaseValidator
.shouldRunConstraints
Methods
addConstraint()
protected
addConstraint(constraint
:IConstraint
<T
,T
>,validatorOptions
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:155
Parameters
Parameter | Type |
---|---|
constraint | IConstraint <T , T > |
validatorOptions | ValidatorOptions |
Returns
this
Inherited from
array()
array(
options
:ValidatorOptions
):ArrayValidator
<T
[],T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:44
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
ArrayValidator
<T
[], T
>
Inherited from
clone()
protected
clone():this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:147
Returns
this
Inherited from
date()
date(
options
:ValidatorOptions
):StringValidator
<T
>
Defined in: projects/shapeshift/src/validators/StringValidator.ts:81
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
default()
default(
value
:Exclude
<T
,undefined
> | () =>Exclude
<T
,undefined
>,options
:ValidatorOptions
):DefaultValidator
<Exclude
<T
,undefined
>>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:81
Parameters
Parameter | Type |
---|---|
value | Exclude <T , undefined > | () => Exclude <T , undefined > |
options | ValidatorOptions |
Returns
DefaultValidator
<Exclude
<T
, undefined
>>
Inherited from
describe()
describe(
description
:string
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:96
Parameters
Parameter | Type |
---|---|
description | string |
Returns
this
Inherited from
email()
email(
options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:49
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
this
getValidationEnabled()
getValidationEnabled():
null
|boolean
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:139
Returns
null
| boolean
Inherited from
BaseValidator
.getValidationEnabled
handle()
protected
handle(value
:unknown
):Result
<T
,ValidationError
>
Defined in: projects/shapeshift/src/validators/StringValidator.ts:101
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
Overrides
ip()
ip(
version
?:4
|6
,options
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:93
Parameters
Parameter | Type |
---|---|
version ? | 4 | 6 |
options ? | ValidatorOptions |
Returns
this
ipv4()
ipv4(
options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:85
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
this
ipv6()
ipv6(
options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:89
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
this
is()
is<
R
>(value
:unknown
):value is R
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:124
Type Parameters
Type Parameter | Default type |
---|---|
R extends string | T |
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
value is R
Inherited from
lengthEqual()
lengthEqual(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:41
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
lengthGreaterThan()
lengthGreaterThan(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:33
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
lengthGreaterThanOrEqual()
lengthGreaterThanOrEqual(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:37
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
lengthLessThan()
lengthLessThan(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:25
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
lengthLessThanOrEqual()
lengthLessThanOrEqual(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:29
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
lengthNotEqual()
lengthNotEqual(
length
:number
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:45
Parameters
Parameter | Type |
---|---|
length | number |
options | ValidatorOptions |
Returns
this
nullable()
nullable(
options
:ValidatorOptions
):UnionValidator
<null
|T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:36
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<null
| T
>
Inherited from
nullish()
nullish(
options
:ValidatorOptions
):UnionValidator
<undefined
|null
|T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:40
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<undefined
| null
| T
>
Inherited from
optional()
optional(
options
:ValidatorOptions
):UnionValidator
<undefined
|T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:32
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
UnionValidator
<undefined
| T
>
Inherited from
or()
or<
O
>(...predicates
: readonlyBaseValidator
<O
>[]):UnionValidator
<T
|O
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:52
Type Parameters
Type Parameter |
---|
O |
Parameters
Parameter | Type |
---|---|
...predicates | readonly BaseValidator <O >[] |
Returns
UnionValidator
<T
| O
>
Inherited from
parse()
parse<
R
>(value
:unknown
):R
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:114
Type Parameters
Type Parameter | Default type |
---|---|
R extends string | T |
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
R
Inherited from
phone()
phone(
options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:97
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
this
regex()
regex(
regex
:RegExp
,options
:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:77
Parameters
Parameter | Type |
---|---|
regex | RegExp |
options | ValidatorOptions |
Returns
this
reshape()
Call Signature
reshape(
cb
: (input
:T
) =>Result
<T
>,options
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:67
Parameters
Parameter | Type |
---|---|
cb | (input : T ) => Result <T > |
options ? | ValidatorOptions |
Returns
this
Inherited from
Call Signature
reshape<
R
,O
>(cb
: (input
:T
) =>R
,options
?:ValidatorOptions
):BaseValidator
<O
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:68
Type Parameters
Type Parameter | Default type |
---|---|
R extends Result <unknown > | - |
O | InferResultType <R > |
Parameters
Parameter | Type |
---|---|
cb | (input : T ) => R |
options ? | ValidatorOptions |
Returns
Inherited from
run()
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:102
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
Inherited from
set()
set(
options
:ValidatorOptions
):SetValidator
<T
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:48
Parameters
Parameter | Type |
---|---|
options | ValidatorOptions |
Returns
SetValidator
<T
>
Inherited from
setParent()
setParent(
parent
:object
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:27
Parameters
Parameter | Type |
---|---|
parent | object |
Returns
this
Inherited from
setValidationEnabled()
setValidationEnabled(
isValidationEnabled
:null
|boolean
| () =>boolean
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:133
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
Inherited from
BaseValidator
.setValidationEnabled
transform()
Call Signature
transform(
cb
: (value
:T
) =>T
,options
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:56
Parameters
Parameter | Type |
---|---|
cb | (value : T ) => T |
options ? | ValidatorOptions |
Returns
this
Inherited from
Call Signature
transform<
O
>(cb
: (value
:T
) =>O
,options
?:ValidatorOptions
):BaseValidator
<O
>
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:57
Type Parameters
Type Parameter |
---|
O |
Parameters
Parameter | Type |
---|---|
cb | (value : T ) => O |
options ? | ValidatorOptions |
Returns
Inherited from
url()
Call Signature
url(
validatorOptions
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:53
Parameters
Parameter | Type |
---|---|
validatorOptions ? | ValidatorOptions |
Returns
this
Call Signature
url(
options
?:UrlOptions
,validatorOptions
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:54
Parameters
Parameter | Type |
---|---|
options ? | UrlOptions |
validatorOptions ? | ValidatorOptions |
Returns
this
uuid()
Call Signature
uuid(
validatorOptions
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:65
Parameters
Parameter | Type |
---|---|
validatorOptions ? | ValidatorOptions |
Returns
this
Call Signature
uuid(
options
?:StringUuidOptions
,validatorOptions
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/StringValidator.ts:66
Parameters
Parameter | Type |
---|---|
options ? | StringUuidOptions |
validatorOptions ? | ValidatorOptions |
Returns
this
when()
when<
Key
,This
>(key
:Key
,options
:WhenOptions
<This
,Key
>,validatorOptions
?:ValidatorOptions
):this
Defined in: projects/shapeshift/src/validators/BaseValidator.ts:88
Type Parameters
Type Parameter | Default type |
---|---|
Key extends WhenKey | - |
This extends BaseValidator <any > | StringValidator <T > |
Parameters
Parameter | Type |
---|---|
key | Key |
options | WhenOptions <This , Key > |
validatorOptions ? | ValidatorOptions |
Returns
this