Gjallarhorn


Validation

Namespace: Gjallarhorn

Basic validation support

Nested types and modules

TypeDescription
InvalidValidationStatus

Used to track the status of invalid validations

ValidationCollector<'a>

Defines the Validation as being in one of three possible states

ModuleDescription
Converters

Library of validation converters which can be used to convert value representations as part of the validation process

Validators

Functions and values

Function or valueDescription
customConverter (...)
Signature: validator:('a -> Choice<'b,string>) -> defaultOnFailure:'b -> step:ValidationCollector<'a> -> ValidationCollector<'b>
Type parameters: 'a, 'b

Create a custom converter validator using a function ('a -> Choice<'b,string>) and default value on conversion failure. Choice2of2 indicates a failure error message. The error message can use {0} for a placeholder for the property name. Conversions always stop collecting on failure.

fixErrors step
Signature: step:ValidationCollector<'a> -> ValidationCollector<'a>
Type parameters: 'a

Fix the current state of errors, bypassing all future validation checks if we're in an error state

fixErrorsWithMessage errorMessage step
Signature: errorMessage:string -> step:ValidationCollector<'a> -> ValidationCollector<'a>
Type parameters: 'a

Fix the current state of errors, bypassing all future validation checks if we're in an error state Also supplies a custom error message to replace the existing

isValid result
Signature: result:ValidationResult -> bool

Check to see if a result is in a valid state

result step
Signature: step:ValidationCollector<'a> -> ValidationResult
Type parameters: 'a

Extracts the resulting errors from an invalid validation, or an empty list for success

resultWithError customErrorMessage step
Signature: customErrorMessage:string -> step:ValidationCollector<'a> -> ValidationResult
Type parameters: 'a

Produces a result of the validation, using a custom error message if an error occurred

validate value
Signature: value:'c -> ValidationCollector<'c>
Type parameters: 'c

Begin a validation chain for a given property

validateWith validator step
Signature: validator:('a -> string option) -> step:ValidationCollector<'a> -> ValidationCollector<'a>
Type parameters: 'a

Create a custom validator using a custom function ('a -> string option) . The error message can use {0} for a placeholder for the property value. None indicates success.

Fork me on GitHub