{"id":32114565,"url":"https://github.com/mrmurphy/validatable","last_synced_at":"2025-12-11T20:56:16.598Z","repository":{"id":57675216,"uuid":"111856222","full_name":"mrmurphy/validatable","owner":"mrmurphy","description":"An Elm library for storing and checking validatable data, live or delayed.","archived":false,"fork":false,"pushed_at":"2018-04-10T14:53:04.000Z","size":6,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-20T15:35:23.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrmurphy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-23T22:57:57.000Z","updated_at":"2018-10-23T21:22:34.000Z","dependencies_parsed_at":"2022-09-18T07:22:49.806Z","dependency_job_id":null,"html_url":"https://github.com/mrmurphy/validatable","commit_stats":null,"previous_names":["splodingsocks/validatable"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mrmurphy/validatable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmurphy%2Fvalidatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmurphy%2Fvalidatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmurphy%2Fvalidatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmurphy%2Fvalidatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrmurphy","download_url":"https://codeload.github.com/mrmurphy/validatable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmurphy%2Fvalidatable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27670060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-11T02:00:11.302Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-20T15:26:26.146Z","updated_at":"2025-12-11T20:56:16.585Z","avatar_url":"https://github.com/mrmurphy.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validatable\n\nA library for storing data that can be invalid, and for checking it with live and delayed checks.\n\n\n# Example\n\nThis library uses \u003chttp://package.elm-lang.org/packages/rtfeldman/elm-validate\u003e under the hood, and in some of its exposed types. Maybe in the future we'll bring those functions in to the library so you don't have to use two. But hey! this is a minimum-viable-package!\n\nHere's a basic example of how you might use this library:\n\nVery first, I'm going to make a type alias called `Error` just to make the type signatures more\nunderstandable. I want my errors to be strings, so the alias will just point `Error` to `String`.\n\n    type alias Error =\n        String\n\nNext, build a validator:\n\n    emailValidator : Validator Error String\n    emailValidator =\n        validator\n            |\u003e withLive (ifBlank \"Hey, I need an email!\")\n            |\u003e withDelayed (ifInvalidEmail \"Sorry, that doesn't look like an email\")\n\nThen store a `Validatable` on your model:\n\n    type alias Model =\n        { email : Validatable Error String\n        }\n\n    init =\n        { email =\n        }\n\nAfter that we can add two message types, for when the field is changed, and for when the field\nis debounced. (Meaning, when the user has stopped editing a field for some lenth of time)\n\nOn the topic of debouncing, there are a number of Elm libraries available to do debouncing inside of the Elm Applicaiton Architecture, or you can build a [Web component](https://www.youtube.com/watch?v=ar3TakwE8o0) for an input that will fire an event after some debounce interval. Or, _if you know what you're doing and you're okay with very very fragile hackery_, you can **dangerously** hand-code an \"onchange\" attribute for your input div and debounce in there, firing a custom event when the debounce happens. But that's the least-safe way to do it.\n\n    type Msg\n        = ChangedEmail String\n        | DebouncedEmail\n\nThen, in your update function, you can check live errors when the field is changed, and check all errors when the debounce comes through. Remember that when a new value for the field comes through, you'll want to re-create the field state before running the validations with `init`.\n\n    update msg model =\n        case msg of\n            ChangedEmail val -\u003e\n                { model | email = runLive emailValidator (init val) } ! []\n\n            DebouncedEmail -\u003e\n                { model | email = runAll emailValidator model.email } ! []\n\nThen, in your view, you can use the `firstError`, `getValue`, and `isValid` to build a little form.\n(I'm making up pretend functions here that will take arguments and render nice HTML controls, so that we don't muddy up the ReadMe too much.)\n\n    view model =\n        div []\n            [ input\n                { errorMessage = getOneError model.email\n                , value = getValue model.email\n                }\n            , button\n                { disabled = not \u003c| isValid model.email\n                , text = \"GO!\"\n                }\n            ]\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmurphy%2Fvalidatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmurphy%2Fvalidatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmurphy%2Fvalidatable/lists"}