API Reference featurevisor_schemas v#2.1.0

Copy Markdown View Source

Modules

Validates data against the schemas a Featurevisor datafile carries, with the same rules, messages and conditions as @featurevisor/schemas in JavaScript.

What a check in code gets besides the value at its path: the whole input and the context.

The HTML validation attributes a field's rules imply, nil where the rules set none.

A schema's handle, or a field's. Everything it does reads the current datafile when it is used, so one handle stays right for the life of an application. A handle is a plain term, safe to keep and share.

One problem with a value, with what an application needs to word it.

What a message function and a translator get besides the issue: the context validation uses.

A choice a field allows: its value, its title when the schema or a source gives one, and every field said about it, the value included.

Choices for a field that come from the application, such as cities from a service. search gets a query and returns {:ok, choices}, each a value or a map with a "value". lookup gets a value and returns {:ok, fields} for the choice it finds, :error for none, which reports enum, or {:error, reason} when it cannot tell, which reports refineError.

A check in code that rules cannot express, such as whether a username is taken. check gets the value at path and a FeaturevisorSchemas.CheckInfo, and returns true when the value passes, false when it does not, or {:error, reason} when it cannot tell. It runs after the rules, and only where they found no issue at or inside its path, nor in a field it reads. A check that errors, raises or exits reports refineError.

Raised by FeaturevisorSchemas.validate!/4 when a value fails, with the issues found.