{"id":13741128,"url":"https://github.com/lpil/formal","last_synced_at":"2026-01-02T08:12:41.346Z","repository":{"id":224816880,"uuid":"764331978","full_name":"lpil/formal","owner":"lpil","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-29T10:46:36.000Z","size":10,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T23:04:56.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Gleam","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/lpil.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-27T22:13:27.000Z","updated_at":"2024-08-20T14:00:39.517Z","dependencies_parsed_at":"2024-02-27T22:19:24.425Z","dependency_job_id":"9c82a4f5-86b0-4971-a56a-ba6857d07319","html_url":"https://github.com/lpil/formal","commit_stats":null,"previous_names":["lpil/formal"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fformal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fformal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fformal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fformal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lpil","download_url":"https://codeload.github.com/lpil/formal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243753988,"owners_count":20342537,"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","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":"2024-08-03T04:00:55.742Z","updated_at":"2026-01-02T08:12:41.341Z","avatar_url":"https://github.com/lpil.png","language":"Gleam","funding_links":[],"categories":["Packages"],"sub_categories":["HTML"],"readme":"# formal\n\nType safe HTML form decoding and validation!\n\n[![Package Version](https://img.shields.io/hexpm/v/formal)](https://hex.pm/packages/formal)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/formal/)\n\n```sh\ngleam add formal@3\n```\n```gleam\nimport formal/form\n\n// Define a type that is to be decoded from the form data\npub type SignUp {\n  SignUp(email: String, password: String)\n}\n\n/// A form that decodes the `Signup` value.\nfn signup_form() -\u003e Form(Signup) {\n  form.new({\n    use email \u003c- form.field(\"email\", {\n      form.parse_email\n    })\n    use password \u003c- form.field(\"password\", {\n      form.parse_string\n      |\u003e form.check_string_length_more_than(7)\n    })\n    use _ \u003c- form.field(\"confirm\", {\n      form.parse_string\n      |\u003e form.check_confirms(password)\n    })\n    form.success(SignUp(email: email, password: password))\n  })\n}\n\n// This function takes the list of key-value string pairs that a HTML form\n// produces. It then decodes the form data into a SignUp value, ensuring that\n// all the fields are present and valid.\n//\npub fn handle_form_submission(values: List(#(String, String))) {\n  let result = \n    signup_form()\n    |\u003e form.add_values(values)\n    |\u003e form.run\n\n  case result {\n    Ok(data) -\u003e {\n      // Do something with the SignUp value here\n    }\n    Error(form) -\u003e {\n      // Re-render the form with the error messages\n    }\n  }\n}\n```\n\n## Examples\n\n- [Backend example with Wisp](https://github.com/lpil/formal/tree/main/examples/backend-with-wisp)\n- [Frontend example with Lustre](https://github.com/lpil/formal/tree/main/examples/frontend-with-lustre)\n\nFurther documentation can be found at \u003chttps://hexdocs.pm/formal\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Fformal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flpil%2Fformal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Fformal/lists"}