[
    {
        "name": "Validate",
        "comment": " Convenience functions for validating data.\n\n    import Validate exposing (ifBlank, ifNotInt, validate)\n\n    type Field = Name | Email | Age\n\n    type alias Model = { name : String, email : String, age : String }\n\n    modelValidator : Validator String Model\n    modelValidator =\n        Validate.all\n            [ ifBlank .name \"Please enter a name.\"\n            , Validate.firstError\n                [ ifBlank .email \"Please enter an email address.\"\n                , ifInvalidEmail .email \"This is not a valid email address.\"\n                ]\n            , ifNotInt .age \"Age must be a whole number.\"\n            ]\n\n    validate modelValidator { name = \"Sam\", email = \"blah\", age = \"abc\" }\n        --> [ \"This is not a valid email address.\", \"Age must be a whole number.\" ]\n\n\n# Validating a subject\n\n@docs Validator, validate\n\n\n# Creating validators\n\n@docs ifBlank, ifNotInt, ifEmptyList, ifEmptyDict, ifEmptySet, ifNothing, ifInvalidEmail, ifTrue, ifFalse\n\n\n# Combining validators\n\n@docs all, any, firstError\n\n\n# Checking values directly\n\n@docs isBlank, isInt, isValidEmail\n\n",
        "unions": [
            {
                "name": "Validator",
                "comment": " A `Validator` contains a function which takes a subject and returns a list\nof errors describing anything invalid about that subject.\n\nPass it to [`validate`](#validate) to get the list of errors.\nAn empty error list means the subject was valid.\n\n",
                "args": [
                    "error",
                    "subject"
                ],
                "cases": []
            }
        ],
        "aliases": [],
        "values": [
            {
                "name": "all",
                "comment": " Run each of the given validators, in order, and return their concatenated\nerror lists.\n\n    import Validate exposing (ifBlank, ifNotInt)\n\n    modelValidator : Validator Model String\n    modelValidator =\n        Validate.all\n            [ ifBlank .name \"Please enter a name.\"\n            , ifBlank .email \"Please enter an email address.\"\n            , ifNotInt .age \"Age must be a whole number.\"\n            ]\n\n",
                "type": "List (Validator error subject) -> Validator error subject"
            },
            {
                "name": "any",
                "comment": " Return `True` if none of the given validators returns any errors for the given\nsubject, and `False` if any validator returns one or more errors.\n",
                "type": "List (Validator error subject) -> subject -> Bool"
            },
            {
                "name": "firstError",
                "comment": " Run each of the given validators, in order, stopping after the first error\nand returning it. If no errors are encountered, return `Nothing`.\n\n    import Validate exposing (ifBlank, ifInvalidEmail, ifNotInt)\n\n\n    type alias Model =\n        { email : String, age : String }\n\n\n    modelValidator : Validator String Model\n    modelValidator =\n        Validate.all\n            [ Validate.firstError\n                [ ifBlank .email \"Please enter an email address.\"\n                , ifInvalidEmail .email \"This is not a valid email address.\"\n                ]\n            , ifNotInt .age \"Age must be a whole number.\"\n            ]\n\n\n    validate modelValidator { email = \" \", age = \"5\" }\n        --> [ \"Please enter an email address.\" ]\n\n    validate modelValidator { email = \"blah\", age = \"5\" }\n        --> [ \"This is not a valid email address.\" ]\n\n    validate modelValidator { email = \"foo@bar.com\", age = \"5\" }\n        --> []\n\n",
                "type": "List (Validator error subject) -> Validator error subject"
            },
            {
                "name": "ifBlank",
                "comment": " Return an error if the given `String` is empty, or if it contains only\nwhitespace characters.\n\n    import Validate exposing (ifBlank, ifNotInt)\n\n    modelValidator : Validator Model String\n    modelValidator =\n        Validate.all\n            [ ifBlank .name \"Please enter a name.\"\n            , ifBlank .email \"Please enter an email address.\"\n            ]\n\n",
                "type": "(subject -> String) -> error -> Validator error subject"
            },
            {
                "name": "ifEmptyDict",
                "comment": " Return an error if a `Dict` is empty.\n",
                "type": "(subject -> Dict comparable v) -> error -> Validator error subject"
            },
            {
                "name": "ifEmptyList",
                "comment": " Return an error if a `List` is empty.\n",
                "type": "(subject -> List a) -> error -> Validator error subject"
            },
            {
                "name": "ifEmptySet",
                "comment": " Return an error if a `Set` is empty.\n",
                "type": "(subject -> Set comparable) -> error -> Validator error subject"
            },
            {
                "name": "ifFalse",
                "comment": " Return an error if a predicate returns `False` for the given\nsubject.\n\n    import Validate exposing (ifFalse)\n\n    modelValidator : Validator Model String\n    modelValidator =\n        ifFalse (\\model -> countSelected model >= 2)\n            \"Please select at least two.\"\n\n",
                "type": "(subject -> Bool) -> error -> Validator error subject"
            },
            {
                "name": "ifInvalidEmail",
                "comment": " Return an error if an email address is malformed.\n",
                "type": "(subject -> String) -> error -> Validator error subject"
            },
            {
                "name": "ifNotInt",
                "comment": " Return an error if the given `String` cannot be parsed as an `Int`.\n",
                "type": "(subject -> String) -> error -> Validator error subject"
            },
            {
                "name": "ifNothing",
                "comment": " Return an error if a `Maybe` is `Nothing`.\n",
                "type": "(subject -> Maybe a) -> error -> Validator error subject"
            },
            {
                "name": "ifTrue",
                "comment": " Return an error if a predicate returns `True` for the given\nsubject.\n\n    import Validate exposing (ifTrue)\n\n    modelValidator : Validator Model String\n    modelValidator =\n        ifTrue (\\model -> countSelected model < 2)\n            \"Please select at least two.\"\n\n",
                "type": "(subject -> Bool) -> error -> Validator error subject"
            },
            {
                "name": "isBlank",
                "comment": " Returns `True` if the given string is nothing but whitespace.\n\n[`ifBlank`](#ifBlank) uses this under the hood.\n\n",
                "type": "String -> Bool"
            },
            {
                "name": "isInt",
                "comment": " Returns `True` if `String.toInt` on the given string returns an `Ok`.\n\n[`ifNotInt`](#ifNotInt) uses this under the hood.\n\n",
                "type": "String -> Bool"
            },
            {
                "name": "isValidEmail",
                "comment": " Returns `True` if the email is malformed.\n\n[`ifInvalidEmail`](#ifInvalidEmail) uses this under the hood.\n\n",
                "type": "String -> Bool"
            },
            {
                "name": "validate",
                "comment": " Return an error if the given predicate returns `True` for the given\nsubject.\n\n    import Validate exposing (ifBlank, ifNotInt, validate)\n\n    type Field = Name | Email | Age\n\n    type alias Model = { name : String, email : String, age : String }\n\n    modelValidator : Validator ( Field, String ) Model\n    modelValidator =\n        Validate.all\n            [ ifBlank .name ( Name, \"Please enter a name.\" )\n            , ifBlank .email ( Email, \"Please enter an email address.\" )\n            , ifNotInt .age ( Age, \"Age must be a whole number.\" )\n            ]\n\n    validate modelValidator { name = \"Sam\", email = \"\", age = \"abc\" }\n        --> [ ( Email, \"Please enter an email address.\" ), ( Age, \"Age must be a whole number.\" ) ]\n\n",
                "type": "Validator error subject -> subject -> List error"
            }
        ],
        "binops": []
    }
]