Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top level declarations without annotations get ignored #56

Open
rtfeldman opened this issue Jan 23, 2018 · 1 comment
Open

Top level declarations without annotations get ignored #56

rtfeldman opened this issue Jan 23, 2018 · 1 comment

Comments

@rtfeldman
Copy link
Collaborator

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

@stoeffel
Copy link
Owner

good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants