Skip to content

TYPE MISMATCH ifInvalidEmail #32

@taj

Description

@taj

I get an error when trying to implement the ifInvalidEmail validator.

Here's my code (that I copied from the Sign Up Form Example):

type alias Form =
    { email : String
    , password : String
    }

type Field
    = Email
    | Password


formValidator : Validator ( Field, String ) Form
formValidator =
    Validate.all
        [ Validate.firstError
            [ ifBlank .email ( Email, "Please enter an email address." )
            , ifInvalidEmail .email ( Email, "This is not a valid email address." )
            ]
        , ifBlank .password ( Password, "Please enter a password." )
        ]

and the error is:

The 2nd argument to `ifInvalidEmail` is not what I expect:

129|             , ifInvalidEmail .email ( Email, "This is not a valid email address." )
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is a tuple of type:

    ( Field, String )

But `ifInvalidEmail` needs the 2nd argument to be:

    String -> error

Same thing happens for ifNotIntvalidators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions