liveBook · Manning

Pointed-validation

As explained in Functional Design and Architecture: Examples in Haskell

pointed-validation is a Haskell library for applicative validation that records the location of errors within possibly hierarchical data structures.

Pointed-validation addresses a common API problem: validating every field while returning all errors in one response instead of stopping at the first failure. It records breadcrumbs to each error, including locations deep inside hierarchical data. section 14.2.4

Its design combines:

  • Applicative-style composition, using fmap (<$>) and ap (<*>) to visit every field. section 14.2.4
  • Composable validators, including condition for field rules and nested for hierarchical structures. section 14.2.4
  • Structured errors containing both a message and a path of field breadcrumbs. section 14.2.4

Nested validation

For an Outer value containing an empty stringField and Inner intField equal to zero, validation can report both failures: one at ["stringField"] and another at ["innerField", "intField"].

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Demonstrates composable validators and nested error paths, stopping short of library internals.
Examples
Uses nested Outer and Inner records, field constraints, and collected ValidationError values.
What it assumes
Assumes familiarity with Haskell records and applicative operators while demonstrating validation composition through concrete structures.
What you can do after
Apply it via pointed-validation combinators to define pure validators that report all field failures with paths.
How it connects
Connects applicative validation with pure functions, combinators, nested structures, fmap, and ap.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.