gege251 / elm-validator-pipeline / Validator.String

Validators for strings.

Validators

notEmpty : x -> Validator x String String

Checks if a string is empty (white spaces allowed).

notBlank : x -> Validator x String String

Checks if a string is empty (white spaces are not allowed).

isEmail : x -> Validator x String String

Checks if a string is valid email. This validator works for most emails, but it is not 100%.

Regex is from: https://emailregex.com/

isPhoneJp : x -> Validator x String String

Checks if a string is a valid Japanese phone number.

Note: I only added japanese regex, because that's what I use, but you can easily use your own regex, or send me a Pull Request.

isUrl : x -> Validator x String String

Checks if a string is valid URL.

Regex is from: https://gist.github.com/dperini/729294

hasLetter : x -> Validator x String String

Checks if a string contains at least one letter.

letterOnly : x -> Validator x String String

Checks if a string only contains letters (white spaces are not allowed).

hasNumber : x -> Validator x String String

Checks if a string contains at least one number.

numberOnly : x -> Validator x String String

Checks if a string only contains numbers.

minLength : x -> Basics.Int -> Validator x String String

Checks if a string is longer than or equal to a given value.

maxLength : x -> Basics.Int -> Validator x String String

Checks if a string is shorter than or equal to a given value.

regexValidator : x -> Maybe Regex -> String -> Validator.Validated x String

Custom string validator using a regular expression.

Casting validators

isInt : x -> String -> Validator.Validated x Basics.Int

Checks if a string can be casted to an integer, and if so, it returns the value.

isFloat : x -> String -> Validator.Validated x Basics.Float

Checks if a string can be casted to a float and if so, it returns the value.