Validate

Namespace: Saon

Provide common validation functions.

Functions and values

Function or valueDescription
all(validators)
Signature: validators:Validator<'T> list -> Validator<'T>
Type parameters: 'T
hasLengthBetween(...)
Signature: minLength:int -> maxLength:int -> propName:string -> value:^T -> ParserResult<^T>
Type parameters: ^T
hasMaxLength maxLength propName value
Signature: maxLength:int -> propName:string -> value:^T -> ParserResult<^T>
Type parameters: ^T
hasMinLength minLength propName value
Signature: minLength:int -> propName:string -> value:^T -> ParserResult<^T>
Type parameters: ^T
isBetweenExclusive(...)
Signature: minValue:'T -> maxValue:bool -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is between minValue and maxValue, exclusive.

isBetweenInclusive(...)
Signature: minValue:'T -> maxValue:bool -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is between minValue and maxValue, inclusive.

isEmail propName value
Signature: propName:string -> value:string -> ParserResult<string>

Validate if value is a valid email address.

We perform a simple check for the presence of the @ character, and that this character is not the first or last character in the string.

isEqual target propName value
Signature: target:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is equal to target.

isGreaterThan minValue propName value
Signature: minValue:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is greater than minValue.

isGreaterThanOrEqualTo(...)
Signature: minValue:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is greater than or equal to minValue.

isIn validValues propName value
Signature: validValues:seq<^T> -> propName:string -> value:^T -> ParserResult<^T>
Type parameters: ^T

Validate if valueis in validValues.

isLessThan maxValue propName value
Signature: maxValue:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is less than minValue.

isLessThanOrEqualTo(...)
Signature: maxValue:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is less than or equal to minValue.

isNotEmpty propName value
Signature: propName:string -> value:seq<'T> -> ParserResult<seq<'T>>
Type parameters: 'T

Validate if value is not empty.

isNotEmptyOrWhitespace propName value
Signature: propName:string -> value:string -> ParserResult<string>

Validate if the string value is not empty or whitespace.

isNotEqual target propName value
Signature: target:'T -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is not equal to target.

isNotNull propName value
Signature: propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if value is not null.

matchesRegex pattern propName value
Signature: pattern:string -> propName:string -> value:string -> ParserResult<string>

Validate if value matches the regex pattern.

must predicate propName value
Signature: predicate:('T -> bool) -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if predicate of value is true.

mustNot predicate propName value
Signature: predicate:('T -> bool) -> propName:string -> value:'T -> ParserResult<'T>
Type parameters: 'T

Validate if predicate of value is false.