This module supports validation.
Validation rules. You can create rules what have any type of validation method and error.
rule : { field : subject -> field, method : field -> Basics.Bool, validWhen : Basics.Bool, error : error } -> Rule error subject
Create an rule.
rule
{ field = .age
, method = (>) 18
, validWhen = True
, error = "Age must be greater than 18."
}
validate : List (Rule error subject) -> subject -> Result (List error) subject
Validate a subject using rules.
validate
[ rule
{ field = .age
, method = (>) 18
, validWhen = True
, error = "Age must be greater than 18."
}
]
{ age = 18 }