Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ case validate someValidator someSubject of
For example:

```elm
import Validate exposing (ifBlank, ifNotInt, validate)
import Validate exposing (ifBlank, ifNotInt, ifEmptyList, validate)


type alias Model =
Expand All @@ -28,7 +28,7 @@ modelValidator =
Validate.all
[ ifBlank .name "Please enter a name."
, ifBlank .email "Please enter an email address."
, ifNotInt .age "Age must be a whole number."
, ifNotInt .age (\_ -> ("Age must be a whole number."))
, ifEmptyList .selections "Please select at least one."
]

Expand Down Expand Up @@ -56,7 +56,7 @@ modelValidator =
Validate.all
[ ifBlank .name ( Name, "Please enter a name." )
, ifBlank .email ( Email, "Please enter an email address." )
, ifNotInt .age ( Age, "Age must be a whole number." )
, ifNotInt .age (\value -> ( Age, value ++ "is not a whole number." ))
, ifEmptyList .selections ( Selections, "Please select at least one." )
]

Expand Down
4 changes: 2 additions & 2 deletions examples/SignupForm.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ modelValidator =
[ ifBlank .name ( Name, "Please enter a name." )
, Validate.firstError
[ ifBlank .email ( Email, "Please enter an email address." )
, ifInvalidEmail .email ( Email, "This is not a valid email address." )
, ifInvalidEmail .email (\value -> ( Email, value ++ " is not a valid email address." ))
]
, ifNotInt .age ( Age, "Age must be a whole number." )
, ifNotInt .age (\_ -> ( Age, "Age must be a whole number." ))
, ifEmptyList .selections ( Selections, "Please select at least one." )
]

Expand Down
12 changes: 6 additions & 6 deletions src/Validate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Validate exposing
[ ifBlank .email "Please enter an email address."
, ifInvalidEmail .email "This is not a valid email address."
]
, ifNotInt .age "Age must be a whole number."
, ifNotInt .age (\_ -> "Age must be a whole number.")
]

validate modelValidator { name = "Sam", email = "blah", age = "abc" }
Expand Down Expand Up @@ -109,7 +109,7 @@ subject.
Validate.all
[ ifBlank .name ( Name, "Please enter a name." )
, ifBlank .email ( Email, "Please enter an email address." )
, ifNotInt .age ( Age, "Age must be a whole number." )
, ifNotInt .age (\_ -> ( Age, "Age must be a whole number." ))
]

validate modelValidator { name = "Sam", email = "", age = "abc" }
Expand Down Expand Up @@ -333,7 +333,7 @@ error lists.
Validate.all
[ ifBlank .name "Please enter a name."
, ifBlank .email "Please enter an email address."
, ifNotInt .age "Age must be a whole number."
, ifNotInt .age (\_ -> "Age must be a whole number.")
]

-}
Expand Down Expand Up @@ -364,10 +364,10 @@ and returning it. If no errors are encountered, return `Nothing`.
modelValidator =
Validate.all
[ Validate.firstError
[ ifBlank .email "Please enter an email address."
, ifInvalidEmail .email "This is not a valid email address."
[ ifBlank .email (\_ -> "Please enter an email address.")
, ifInvalidEmail .email (\_ -> "This is not a valid email address.")
]
, ifNotInt .age "Age must be a whole number."
, ifNotInt .age (\_ -> "Age must be a whole number.")
]


Expand Down