refrakt/validate
Values
pub fn format(
errors: List(#(String, String)),
value: String,
field: String,
predicate: fn(String) -> Bool,
message: String,
) -> List(#(String, String))
Check that a string value matches a format predicate.
pub fn inclusion(
errors: List(#(String, String)),
value: String,
field: String,
allowed: List(String),
message: String,
) -> List(#(String, String))
Check that a string value matches one of the allowed values.
pub fn max_length(
errors: List(#(String, String)),
value: String,
field: String,
max: Int,
message: String,
) -> List(#(String, String))
Check that a string value has at most max characters.
Skips the check if the field already has an error.
pub fn min_length(
errors: List(#(String, String)),
value: String,
field: String,
min: Int,
message: String,
) -> List(#(String, String))
Check that a string value has at least min characters.
Skips the check if the field already has an error (avoids duplicate messages).