elm-verify-examples icon indicating copy to clipboard operation
elm-verify-examples copied to clipboard

Top level declarations without annotations get ignored

Open rtfeldman opened this issue 6 years ago • 1 comments

I ran into this recently. I'd have expected this to work fine:

import Validate exposing (ifBlank, ifInvalidEmail, ifNotInt)

modelValidator =
    Validate.all
        [ Validate.firstError
            [ ifBlank .email "Please enter an email address."
            , ifInvalidEmail .email "This is not a valid email address."
            ]
        , ifNotInt .age "Age must be a whole number."
        ]

validate modelValidator { email = " ", age = "5" }
    --> [ "Please enter an email address." ]

validate modelValidator { email = "foo@bar", age = "5" }
    --> [ "This is not a valid email address." ]

validate modelValidator { email = "[email protected]", age = "5" }
    --> []

However, this doesn't compile (says modelValidator is undefined) unless I add this annotation:

modelValidator : Validator String  { email : String, age : String }

It's

rtfeldman avatar Jan 23 '18 18:01 rtfeldman

good catch.

stoeffel avatar Jan 23 '18 18:01 stoeffel