{"id":13801315,"url":"https://github.com/jap-company/fields","last_synced_at":"2025-05-13T11:31:03.212Z","repository":{"id":37040305,"uuid":"497559566","full_name":"jap-company/fields","owner":"jap-company","description":"Scala validation library","archived":false,"fork":false,"pushed_at":"2022-08-09T21:26:10.000Z","size":4684,"stargazers_count":48,"open_issues_count":6,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T16:57:23.996Z","etag":null,"topics":["cats","functional-programming","library","macros","scala","short-circuit","validation","validation-library","zio"],"latest_commit_sha":null,"homepage":"https://jap-company.github.io/fields/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jap-company.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-29T10:37:51.000Z","updated_at":"2024-10-21T19:56:22.000Z","dependencies_parsed_at":"2022-06-25T08:05:24.336Z","dependency_job_id":null,"html_url":"https://github.com/jap-company/fields","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jap-company%2Ffields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jap-company%2Ffields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jap-company%2Ffields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jap-company%2Ffields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jap-company","download_url":"https://codeload.github.com/jap-company/fields/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932800,"owners_count":21986448,"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":["cats","functional-programming","library","macros","scala","short-circuit","validation","validation-library","zio"],"created_at":"2024-08-04T00:01:21.527Z","updated_at":"2025-05-13T11:31:00.676Z","avatar_url":"https://github.com/jap-company.png","language":"Scala","readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/jap-logo.png\" alt=\"Jap Logo\"/\u003e\n\u003c/p\u003e\n\n# Fields\n\n[![badge-scaladex]][link-scaladex] [![badge-maven]][link-maven] [![badge-ci]][link-ci] [![badge-scaladoc]][link-scaladoc] [![badge-scala-ukraine]][link-scala-ukraine]\n\nFields is a Scala validation library that you should use because it is:\n\n- _**F**inal Tagless_. Choose any Effect, Validated, or Error types.\n- _**I**nformative_. Error paths help understanding where the error occurred.\n- _**E**xpressive_. Rich, extendable validation syntax.\n- _**L**ightweight_. The core module has no-dependencies.\n- _**D**auntless_. Have no fear of complex validations with `Rule` type.\n- _**S**hort-circuit_. Avoid running undesired validation side-effects.\n\n# Teaser\n\n```scala\n// Here we pass validation dependencies using implicits, but you could be doing this the way you prefer\ndef policy(implicit tokenService: TokenService, userService: UserService): Policy[RegisterRequest] = Policy\n  .builder[RegisterRequest]\n  .subRule(_.age)(_ \u003e= 18, _ \u003c= 110)\n  .subRule(_.email)(_.map(_.value).matchesRegex(EmailRegex))\n  .subRule(_.password)(_.nonEmpty, _.minSize(4), _.maxSize(100))\n  .subRule(_.password, _.passwordRepeat)(_ equalTo _)\n  .subRule(_.username)(validateUsername)\n  .subRule(_.token)(_.ensureF(tokenService.validateToken, _.failMessage(\"invalid-token\")))\n  .build\n\n// Extract complex validations to reusable methods.\ndef validateUsername(username: Field[String])(implicit userService: UserService): MRule =\n    username.minSize(1) \u0026\u0026\n    username.maxSize(10) \u0026\u0026\n    MRule.flatten {\n      userService.findByUsername(username.value).map {\n        case Some(_) =\u003e username.failMessage(\"username-already-exists\")\n        case None    =\u003e MRule.valid\n      }\n    }\n```\n\n## Quicklinks\n\n- [Microsite](https://jap-company.github.io/fields)\n- [Medium](https://medium.com/@oleh.dubynskiy/fields-scala-validation-library-86ac818cd704)\n- [Contributor's Guide](https://jap-company.github.io/fields/docs/contributing)\n- [License](LICENSE)\n- [Issues](https://github.com/jap-company/fields/issues)\n- [Pull Requests](https://github.com/jap-company/fields/pulls)\n\n# [Learn More on the Fields Microsite](https://jap-company.github.io/fields)\n\n[link-scaladex]: https://index.scala-lang.org/jap-company/fields/fields-core \"Scaladex\"\n[link-maven]: https://maven-badges.herokuapp.com/maven-central/company.jap/fields-core_2.13 \"Maven\"\n[link-ci]: https://github.com/jap-company/fields/actions?query=workflow%3A%22CI%22 \"CI\"\n[link-scala-ukraine]: https://github.com/scala-ukraine/knowledge-base \"Scala Ukraine\"\n[link-scaladoc]: https://jap-company.github.io/fields/api \"Scaladoc\"\n[badge-ci]: https://github.com/jap-company/fields/workflows/CI/badge.svg \"CI\"\n[badge-maven]: https://maven-badges.herokuapp.com/maven-central/company.jap/fields-core_2.13/badge.svg \"Maven\"\n[badge-scaladex]: https://index.scala-lang.org/jap-company/fields/fields-core/latest-by-scala-version.svg?platform=jvm \"Scaladex\"\n[badge-scala-ukraine]: https://img.shields.io/badge/Scala-Ukraine-EBD038?labelColor=4172CC \"Scala Ukraine\"\n[badge-scaladoc]: https://img.shields.io/badge/scaladoc-read-brightgreen \"Scaladoc\"\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Data Binding and Validation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjap-company%2Ffields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjap-company%2Ffields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjap-company%2Ffields/lists"}