Raxol.Config.Schema (Raxol v2.0.1)

View Source

Configuration schema definitions and validation.

Defines the structure, types, and constraints for all configuration options in Raxol, providing compile-time and runtime validation.

Summary

Functions

Generates documentation for configuration options.

Gets the schema for a specific configuration path.

Returns the complete configuration schema.

Validates a configuration value against a schema.

Validates an entire configuration map.

Types

constraint()

@type constraint() ::
  {:min, number()}
  | {:max, number()}
  | {:min_length, non_neg_integer()}
  | {:max_length, non_neg_integer()}
  | {:format, Regex.t()}
  | {:custom, fun()}

field_schema()

@type field_schema() :: %{
  type: schema_type(),
  required: boolean(),
  default: term(),
  constraints: [constraint()],
  description: String.t(),
  deprecated: boolean()
}

schema_type()

@type schema_type() ::
  :string
  | :integer
  | :float
  | :boolean
  | :atom
  | {:list, schema_type()}
  | {:map, schema_type()}
  | {:enum, [term()]}
  | {:struct, module()}
  | {:one_of, [schema_type()]}

Functions

generate_docs()

Generates documentation for configuration options.

get_schema(path)

Gets the schema for a specific configuration path.

schema()

Returns the complete configuration schema.

validate(value, schema)

Validates a configuration value against a schema.

validate_config(config, schema \\ schema())

Validates an entire configuration map.