validation
stdlib/core/validation.hk: ValidationError, the where-block failure.
Returned in the Err arm of the compiler-generated pure Type.new of an opaque type that declares a where block, when a validity predicate fails. The fields are a structured snapshot of the failure so the caller can inspect it after a match; Display renders a human-readable message.
ValidationError
struct ValidationError
type_name: string
predicate_source: string
label: Option<string>
field_values: Map<string, string>
location: string
end
labelsuffix
def _label_suffix(label: Option<string>) -> string
fieldssuffix
def _fields_suffix(fv: Map<string, string>) -> string
impl Display<ValidationError>
to_string
def to_string(self) -> string
Renders the failure as ValidationError: <Type> failed predicate '<src>' at <location>, with an optional (label) and a fields snapshot.
fv: Map<string, string> = Map.empty()
e = ValidationError(type_name="Email", predicate_source="P", label=None, field_values=fv, location="main.hk:3:7")
e.to_string() => "ValidationError: Email failed predicate 'P' at main.hk:3:7"