Backplane.JsonSchema.Compiler.Predicates (backplane_json_schema v1.10.58)

Copy Markdown

Pure predicates for JSON Schema validation constraints.

Functions return :ok or {:error, context}. Non-applicable data types pass validation (e.g., pattern checking on non-strings). Regex engine errors abort validation rather than returning an invertible schema mismatch.

Summary

Functions

Checks const.

Checks exclusiveMaximum.

Checks exclusiveMinimum.

Checks maxItems.

Checks maxLength, returning an error for malformed UTF-8.

Checks maxProperties.

Checks maximum.

Checks minItems.

Checks minLength, returning an error for malformed UTF-8.

Checks minProperties.

Checks minimum.

Checks multipleOf.

Checks if data matches the specified JSON Schema type(s).

Checks uniqueItems. Uses == semantics (1 equals 1.0).

Functions

check_const(data, const)

@spec check_const(term(), term()) :: :ok | {:error, map()}

Checks const.

check_enum(data, values)

@spec check_enum(term(), list()) :: :ok | {:error, map()}

Checks enum.

check_exclusive_maximum(data, limit)

Checks exclusiveMaximum.

check_exclusive_minimum(data, limit)

Checks exclusiveMinimum.

check_max_items(data, max)

Checks maxItems.

check_max_length(data, max)

Checks maxLength, returning an error for malformed UTF-8.

check_max_properties(data, max)

Checks maxProperties.

check_maximum(data, max)

Checks maximum.

check_min_items(data, min)

Checks minItems.

check_min_length(data, min)

Checks minLength, returning an error for malformed UTF-8.

check_min_properties(data, min)

Checks minProperties.

check_minimum(data, min)

@spec check_minimum(number(), number()) :: :ok | {:error, map()}

Checks minimum.

check_multiple_of(data, factor)

Checks multipleOf.

check_pattern(data, regex, path \\ [])

@spec check_pattern(term(), Regex.t(), list()) :: :ok | {:error, map()}

Checks pattern.

check_type(data, types)

@spec check_type(term(), String.t() | [String.t()]) ::
  :ok | {:error, Backplane.JsonSchema.Types.ErrorContext.t()}

Checks if data matches the specified JSON Schema type(s).

check_unique_items(data, arg2)

Checks uniqueItems. Uses == semantics (1 equals 1.0).