validator/list
Functions
pub fn every(
validator: fn(a) -> Result(b, #(c, List(c))),
) -> fn(List(a)) -> Result(List(b), #(c, List(c)))
Validate a list of items.
Run the given validator for each item returning all the errors.
Example
type Collection = { Collection(items: List(String) ) }
let list_validator = v_list.every(
v_string.min_length("Must be at least 3", 3)
)
let validator = fn(collection: Collection) {
v.build1(Collection)
|> v.validate(collection.items, list_validator)
}
pub fn is_not_empty(
error: a,
) -> fn(List(b)) -> Result(List(b), #(a, List(a)))
Validate that a list is not empty
pub fn max_length(
error: a,
max: Int,
) -> fn(List(b)) -> Result(List(b), #(a, List(a)))
Validate the max number of items in a list
pub fn min_length(
error: a,
min: Int,
) -> fn(List(b)) -> Result(List(b), #(a, List(a)))
Validate the min number of items in a list