nori/codegen/gleam_constraints
Gleam source for the checks a value must pass under its schema’s validation keywords (#3). Shared by the record decoders and the query readers, so a body field and a query parameter with the same constraints accept and reject the same values.
Not enforced: pattern (it would make every consumer depend on a regex
package), multipleOf, uniqueItems, and the OpenAPI 3.0 boolean form of
exclusiveMinimum/exclusiveMaximum, which the parser reads as no bound.
Types
Values
pub fn count_checks(
c: ir.Constraints,
var: String,
) -> List(Check)
Checks on the number of items in a list bound to var.
A bound of 0 or 1 is an emptiness test, written as one: the compiler warns
that list.length(v) >= 1 walks the whole list to answer it.
pub fn describe(base: String, checks: List(Check)) -> String
The type name used in a rejection message: "integer >= 1 and <= 5".
pub fn scalar_checks(
c: ir.Constraints,
prim: ir.PrimitiveType,
var: String,
) -> List(Check)
Checks on a scalar of the given primitive bound to var. Bounds only apply
to numbers and lengths only to strings, as in JSON Schema, where a keyword
for another type is ignored.
pub fn type_name(prim: ir.PrimitiveType) -> String
The JSON type name of a primitive, for rejection messages.