ExParamsSchema.Definition (ex_params_schema v0.1.1)

Copy Markdown View Source

Normalizes and validates field definitions written in the DSL and map forms.

This module is the entry point for the related functionality. Individual operations are split among Normalizer, Validator, and Compiler.

Summary

Functions

Compiles a map-based schema definition into validated fields.

Compiles field definitions into structs used by the parser.

Converts a map-based schema into a list of field definitions.

Returns the mapping between DSL options and JSON Schema keywords.

Splits a type definition into its type and options and normalizes it to the internal representation.

Normalizes all field definitions and validates unique names and input keys.

Types

normalized_definition()

@type normalized_definition() ::
  {type :: ExParamsSchema.field_type(),
   options :: ExParamsSchema.field_options()}

Functions

compile!(schema)

@spec compile!(%{required(atom()) => ExParamsSchema.definition()}) :: [
  ExParamsSchema.Definition.Field.t()
]

Compiles a map-based schema definition into validated fields.

compile_fields!(fields)

@spec compile_fields!([ExParamsSchema.field()]) :: [
  ExParamsSchema.Definition.Field.t()
]

Compiles field definitions into structs used by the parser.

fields_from_map!(schema)

@spec fields_from_map!(%{required(atom()) => ExParamsSchema.definition()}) :: [
  ExParamsSchema.field()
]

Converts a map-based schema into a list of field definitions.

json_schema_options()

@spec json_schema_options() :: Keyword.t(String.t())

Returns the mapping between DSL options and JSON Schema keywords.

normalize!(definition)

Splits a type definition into its type and options and normalizes it to the internal representation.

normalize_fields!(fields)

@spec normalize_fields!([ExParamsSchema.field()]) :: [ExParamsSchema.field()]

Normalizes all field definitions and validates unique names and input keys.