Modules and compatibility
Fields v1 separates the validation front ends from the small shared core.
| Module | Purpose | Scala versions | Main external dependencies |
|---|---|---|---|
fields-core | Rules, policies, effects, validation containers, paths, errors, and Circe decoder syntax | 2.12, 2.13 and 3 | Circe is optional |
fields-value | Value-carrying Field DSL | 2.12, 2.13 and 3 | Core only |
fields-lens | Reusable lens/policy DSL and path macros | 2.12, 2.13 and 3 | Core only |
fields-cats | Cats Effect, Validated, Chain, Eval, and error-container integration | 2.12, 2.13 and 3 | Cats Core |
fields-zio | ZIO effect and validation helpers | 2.12, 2.13 and 3 | ZIO 2 |
fields-zio-blocks-schema | Native ZIO Blocks SchemaError instances and policy-backed schema validation for Value and Lens | 2.13 and 3 | Fields Core and ZIO Blocks Schema |
Add only the front end and integrations your application uses. Transitive dependencies provide core, but depending on core explicitly is useful when its types are part of your public API.
libraryDependencies ++= Seq(
"io.github.0lejk4" %% "fields-core" % "1.0.0",
"io.github.0lejk4" %% "fields-value" % "1.0.0",
"io.github.0lejk4" %% "fields-lens" % "1.0.0",
"io.github.0lejk4" %% "fields-cats" % "1.0.0", // optional
"io.github.0lejk4" %% "fields-zio" % "1.0.0", // optional
"io.github.0lejk4" %% "fields-zio-blocks-schema" % "1.0.0", // optional integration, Scala 2.13/3
)
Choosing a front endβ
- Choose Value when validation is local and direct access to the current value/path makes rules easiest to write.
- Choose Lens when policies should be reusable without wrapping the validated model in
Fieldvalues.
Both use the same core RuleK, PolicyK, Effect, Validated, path, and error concepts.