Update part5

This commit is contained in:
Richard Feldman
2018-05-01 21:48:38 -04:00
parent d22a7a9c47
commit 0f673557eb
17 changed files with 111 additions and 18301 deletions

View File

@@ -143,7 +143,7 @@ update msg model =
RegisterCompleted (Err error) ->
let
errorMessages =
case error of
case Debug.log "ERROR:" error of
Http.BadStatus response ->
response.body
|> decodeString (field "errors" errorsDecoder)
@@ -186,10 +186,23 @@ modelValidator =
Validate.all
[ ifBlank .username ( Username, "username can't be blank." )
, ifBlank .email ( Email, "email can't be blank." )
, ifBlank .password ( Password, "password can't be blank." )
, Validate.fromErrors passwordLength
]
minPasswordChars : Int
minPasswordChars =
6
passwordLength : Model -> List Error
passwordLength { password } =
if String.length password < minPasswordChars then
[ ( Password, "password must be at least " ++ toString minPasswordChars ++ " characters long." ) ]
else
[]
errorsDecoder : Decoder (List String)
errorsDecoder =
decode (\email username password -> List.concat [ email, username, password ])