Repository F# setup
open Reified
open Reified.Refinements
open Reified.Result
open Reified.Schema.Json

Constraints

Reified.Constraint describes which typed values are acceptable. A constraint can be checked directly, reused by a refined type, attached to a Schema field, inspected for documentation, and rendered in another language.

dotnet add package Reified.Constraint
open Reified
open Reified.ConstraintDSL

let username = Constraint.all [ present; minLength 3; maxLength 30 ]

Constraint.check username "ada"
// Ok ()

Constraint.check username ""
// Error [ Blank; InvalidLength (MinimumLength 3, Some 0) ]

Constraints return the standard F# Result<unit, Violation>. They do not depend on Reified.Result; use that package, FsToolkit.ErrorHandling, or ordinary pattern matching when you need to compose the result with other work.

Start here

Use Parsing when serialized text must first become a typed value. Use Refined when successful admission should be recorded in the type. Use Schema when fields of a structured input need paths and accumulated diagnostics.