You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 2, 2024. It is now read-only.
Hello, I'm having problems using elm-form with a custom API to validate one of my fields. My solution ATM "kinda" works but I think that an example on the documentation for this very common situation would be beneficial, once I have this working properly I'll add it to the example and docs.
update : Message -> Model -> (Model, Cmd Message)
update message ({ form } as model) =
case message of
ValidateEmailUniqueness response ->
case response of
Ok _ ->
( { model | emailTaken = False }, Cmd.none )
Err _ ->
( { model | emailTaken = True }, Cmd.none )
This is how I "manually" set a random Boolean on my model, and the part that probably needs updating as it's not using elm-form as it should (it's not using it at all actually).
The HTTP validation is actually triggered using elm-form:
Form.Input "user[email]" Form.Text (Form.Field.String string) ->
let
emailField = Form.getFieldAsString "user[email]" form_
request = emailValidationRequest emailField.value
in
case emailField.error of
Nothing ->
({ model | form = form_ }, Http.send ValidateEmailUniqueness request)
_ ->
({ model | form = form_ }, Cmd.none)
I think the main problem here is that I'm not able to put my work into how elm-form validation works, for example here:
(field "user[email]" (email |> andThen nonEmpty))
Main problem obviously is that even when emailTaken is True I can submit the form.
Any suffestion on how to accomplish this?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello, I'm having problems using elm-form with a custom API to validate one of my fields. My solution ATM "kinda" works but I think that an example on the documentation for this very common situation would be beneficial, once I have this working properly I'll add it to the example and docs.
This is how I "manually" set a random Boolean on my model, and the part that probably needs updating as it's not using elm-form as it should (it's not using it at all actually).
The HTTP validation is actually triggered using elm-form:
I think the main problem here is that I'm not able to put my work into how elm-form validation works, for example here:
Main problem obviously is that even when emailTaken is True I can submit the form.
Any suffestion on how to accomplish this?
The text was updated successfully, but these errors were encountered: