### Configure remote resource proxying Source: https://hexdocs.pm/exonerate/index.html Example of setting the proxy option to substitute remote resource URLs with a local address. ```elixir [proxy: [{"https://my.remote.resource/", "http://localhost:4000"}]] ``` -------------------------------- ### Create context from options Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Initializes a new Context struct using a keyword list of options. ```elixir @spec from_opts(keyword()) :: t() ``` -------------------------------- ### Create new declaration Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Creates a new declaration instance from a resource, pointer, and context or options. ```elixir @spec new(String.t(), JsonPtr.t(), keyword() | Exonerate.Context.t()) :: t() ``` -------------------------------- ### Convert context to options Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Transforms a Context struct back into a keyword list. ```elixir @spec to_opts(t()) :: keyword() ``` -------------------------------- ### Enable format validation in Exonerate Source: https://hexdocs.pm/exonerate/formatting.html Pass the :format option to an Exonerate macro to enable validation for specific schema formats. ```elixir Exonerate.function_from_string(:def, :validate, """ {"type": "string", "format": "email"} """, format: true) ``` -------------------------------- ### Enable Decimal mode in Exonerate Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Configure decimal mode globally or for specific JSON pointer paths when generating validation functions. ```elixir # All numeric locations use Decimal arithmetic Exonerate.function_from_string(:def, :validate, schema, decimal: :all) # Specific paths use Decimal arithmetic Exonerate.function_from_string(:def, :validate, schema, decimal: [at: ["/properties/price", "/properties/amount"]] ) ``` -------------------------------- ### Map file extensions to MIME types Source: https://hexdocs.pm/exonerate/index.html Configures custom file extension to MIME type mappings for schema parsing. ```elixir # Parse .schema files as JSON Exonerate.function_from_file( :def, :validate, "types.schema", mimetype_mapping: [{".schema", "application/json"}] ) ``` -------------------------------- ### register_resource(schema, name, opts \ []) Source: https://hexdocs.pm/exonerate/index.html Saves a schema in the compile-time registry under the given name for later use. ```APIDOC ## register_resource(schema, name, opts \ []) ### Description Saves in the compile-time registry a schema under the given name. The schema can then be used to generate a validation function with function_from_resource/3. ### Parameters - **schema** (term) - Required - The JSON schema to register. - **name** (string) - Required - The name to associate with the schema. - **opts** (keyword) - Optional - Additional options for the registration. ``` -------------------------------- ### Generate validation functions from YAML Source: https://hexdocs.pm/exonerate/index.html Demonstrates generating validation functions using YAML-formatted schemas from files or string literals. ```elixir # Using a YAML-formatted schema file Exonerate.function_from_file(:def, :validate, "schema.yaml") # content_type is auto-detected from .yaml extension # Using a YAML string directly Exonerate.function_from_string(:def, :validate, """ type: object properties: name: type: string """, content_type: "application/yaml") ``` -------------------------------- ### enabled?(resource, pointer, opts) Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Checks if decimal mode is active for a specific location in the schema. ```APIDOC ## enabled?(resource, pointer, opts) ### Description Checks if decimal mode is enabled at the given resource/pointer location. ``` -------------------------------- ### function_from_resource(type, function_name, resource, opts \ []) Source: https://hexdocs.pm/exonerate/index.html Generates a series of functions from a previously provided JSONSchema found registered using register_resource/3. ```APIDOC ## function_from_resource(type, function_name, resource, opts \ []) ### Description Generates a series of functions from a previously provided JSONSchema found registered using register_resource/3. The resource parameter must be a string literal defined earlier in a register_resource/3 call. ### Parameters - **type** (atom) - Required - The type of validation function to generate. - **function_name** (atom) - Required - The name of the generated function. - **resource** (string) - Required - The name of the registered resource. - **opts** (keyword) - Optional - Additional options for the macro. ``` -------------------------------- ### Collect schema declarations Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Phase 1 of compilation; must be invoked before code generation macros. ```elixir @spec collect_declarations(module(), String.t(), JsonPtr.t(), keyword()) :: :ok ``` -------------------------------- ### fetch_remote!(resource, opts) Source: https://hexdocs.pm/exonerate/Exonerate.Remote.html Fetches remote content from a given URI. This function raises an error if the remote resource does not return a 200 status code or if a connection error occurs. ```APIDOC ## fetch_remote!(resource, opts) ### Description Fetches remote content from a specified URI using the Req library. This function is intended for use when creating custom adapters or managing remote schemas. ### Signature `fetch_remote!(URI.t(), keyword()) :: {encoded_json :: String.t(), content_type :: String.t() | nil}` ### Parameters - **resource** (URI.t()) - The URI of the remote content to fetch. - **opts** (keyword()) - Additional options for the request. ### Behavior - Fails if the remote resource does not return a 200 status code. - Raises an exception for any connection errors. ``` -------------------------------- ### Generic module lookup Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Performs a module lookup based on a specified category and name. ```elixir @spec lookup(:type | :combining | :object | :array | :format, String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.lookup(:type, "string") Exonerate.Type.String iex> Exonerate.Modules.lookup(:combining, "allOf") Exonerate.Combining.AllOf ``` -------------------------------- ### Retrieve all type names Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Returns a list of all supported JSON type names. ```elixir @spec all_types() :: [String.t()] ``` -------------------------------- ### register_resource/3 Source: https://hexdocs.pm/exonerate/index.html Saves a schema in the compile-time registry under a given name for reuse. ```APIDOC ## register_resource(schema, name, opts \\ []) ### Description Saves in the compile-time registry a schema under the given name. The schema can then be used to generate a validation function with function_from_resource/3. ### Parameters - **schema** (string) - The schema definition. - **name** (atom) - The identifier for the registered resource. - **opts** (keyword list) - Optional configuration settings. ### Options - **:content_type** (string) - Specifies the MIME type used to parse the schema definition itself (e.g., "application/json", "application/yaml"). - **:mimetype_mapping** (list) - A proplist of {extension, mimetype} tuples for mapping file extensions. ``` -------------------------------- ### compare(a, b) Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Compares two Decimal values and returns the comparison result. ```APIDOC ## compare(a, b) ### Description Compares two Decimal values. Returns :lt, :eq, or :gt. ``` -------------------------------- ### encode(input) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Punycode.html Encodes a unicode charlist to a punycode string. ```APIDOC ## encode(input) ### Description Encode a unicode charlist to punycode. ### Signature `encode(charlist()) :: charlist()` ### Examples ```elixir Exonerate.Formats.Punycode.encode(~c"bücher") # => ~c"bcher-kva" ``` ``` -------------------------------- ### Retrieve type constraints Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Returns the list of type constraints or a provided default if none are set. ```elixir @spec get_only(t(), [String.t()]) :: [String.t()] ``` -------------------------------- ### function_from_file(type, function_name, path, opts \ []) Source: https://hexdocs.pm/exonerate/index.html Generates a series of functions that validates a JSON schema in a file at the provided path. ```APIDOC ## function_from_file(type, function_name, path, opts \ []) ### Description Generates a series of functions that validates a JSON schema in a file at the provided path. The path parameter must be a Path.t/0 value. ### Parameters - **type** (atom) - Required - The type of validation function to generate. - **function_name** (atom) - Required - The name of the generated function. - **path** (Path.t) - Required - The file path to the JSON schema. - **opts** (keyword) - Optional - Additional options for the macro. ``` -------------------------------- ### Merge options into context Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Updates an existing context with new keyword options. ```elixir @spec merge( t(), keyword() ) :: t() ``` -------------------------------- ### Define and Apply Custom Format Filters Source: https://hexdocs.pm/exonerate/formatting.html Implements a phone number validation module and demonstrates applying it to JSON schemas using global and path-specific configuration. ```elixir defmodule MyApp.Formats.PhoneNumber do def validate(string) do if Regex.match?(~r/^\+?[1-9]\d{1,14}$/, string) do :ok else {:error, "invalid phone number format"} end end end # Use with :type option (applies globally) Exonerate.function_from_string(:def, :validate, """ {"type": "string", "format": "phone"} """, format: [type: [{"phone", MyApp.Formats.PhoneNumber}]]) # Use with :at option (applies at specific location) Exonerate.function_from_string(:def, :validate, """ {"type": "object", "properties": {"phone": {"type": "string", "format": "phone"}}} """, format: [at: [{"/properties/phone", MyApp.Formats.PhoneNumber}]]) ``` -------------------------------- ### Build Merged Property Registry Source: https://hexdocs.pm/exonerate/Exonerate.PropertyRegistry.html Returns a map containing properties and pattern properties extracted from optimizable sub-schema indices. ```elixir properties: %{property_name => [{sub_index, pointer, schema}]}, pattern_properties: [{pattern, sub_index, pointer, schema}] ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.IdnHostname.html Creates a parser function that validates strings against IDN hostname requirements. ```APIDOC ## filter(opts \\ []) ### Description Creates a parser function (defaulting to `~idn-hostname/1`) that validates if a given string is a valid internationalized hostname. The function returns `{:ok}` on success or `{:error, reason}` on failure. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the generated parser. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~idn-hostname"`. ``` -------------------------------- ### Set tracked mode Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Configures the tracking mode for the current context. ```elixir @spec with_tracked(ctx, :object | :array | nil) :: t() ``` -------------------------------- ### decode(input) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Punycode.html Decodes a punycode string to a unicode charlist. Raises ArgumentError if the input is invalid. ```APIDOC ## decode(input) ### Description Decodes a punycode string to a unicode charlist. Raises ArgumentError if the punycode is invalid or decodes to characters that are not valid for domain names. ### Signature `decode(charlist()) :: charlist()` ### Examples ```elixir Exonerate.Formats.Punycode.decode(~c"bcher-kva") # => ~c"bücher" ``` ``` -------------------------------- ### Scrub context options Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Clears combining-specific fields (:only, :tracked, :seen) from the context. ```elixir @spec scrub(t()) :: t() ``` -------------------------------- ### from_schema(value) Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Converts a schema value to Decimal for comparison purposes. ```APIDOC ## from_schema(value) ### Description Converts a schema value (from JSON) to Decimal for comparison. Schema values can be numbers or strings. ``` -------------------------------- ### filter() Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Hostname.html Creates a parser function that validates a string against hostname requirements. ```APIDOC ## filter() ### Description Creates a parser function (defaulting to `~hostname/1`) that validates if a string is a valid hostname according to RFC 1123 and RFC 952. ### Parameters - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~hostname"`. ### Return Value - **{:ok}** - Returned if the string is a valid hostname. - **{:error, reason}** - Returned if the string is not a valid hostname. ``` -------------------------------- ### zero() Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Returns a Decimal representation of zero. ```APIDOC ## zero() ### Description Returns Decimal representing zero. ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.JsonPointer.html Creates a NimbleParsec parser named ~json-pointer/1. This macro generates a function that validates strings against the JSON pointer specification. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser `~json-pointer/1`. This macro generates a function that returns `{:ok, ...}` if the input is a valid JSON pointer or `{:error, reason, ...}` if it is invalid. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the generated function. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~json-pointer"`. ``` -------------------------------- ### Fetch remote content specification Source: https://hexdocs.pm/exonerate/Exonerate.Remote.html Defines the signature for the fetch_remote! function, which accepts a URI and options, returning the encoded JSON and content type. ```elixir @spec fetch_remote!( URI.t(), keyword() ) :: {encoded_json :: String.t(), content_type :: String.t() | nil} ``` -------------------------------- ### function_from_string(type, function_name, schema_ast, opts \ []) Source: https://hexdocs.pm/exonerate/index.html Generates a series of functions that validates a provided JSONSchema. ```APIDOC ## function_from_string(type, function_name, schema_ast, opts \ []) ### Description Generates a series of functions that validates a provided JSONSchema. ### Parameters - **type** (atom) - Required - The type of validation function to generate. - **function_name** (atom) - Required - The name of the generated function. - **schema_ast** (term) - Required - The AST of the JSON schema. - **opts** (keyword) - Optional - Additional options for the macro. ``` -------------------------------- ### Lookup format validator module Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Retrieves the module associated with a specific format validator name. ```elixir @spec format(String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.format("email") Exonerate.Formats.Email iex> Exonerate.Modules.format("uri") Exonerate.Formats.Uri ``` -------------------------------- ### Scrub keyword options Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Removes combining-specific options from a keyword list. ```elixir @spec scrub_opts(keyword()) :: keyword() ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.RelativeJsonPointer.html Creates a NimbleParsec parser for relative JSON pointers. The generated function returns {:ok, ...} for valid pointers or {:error, reason, ...} for invalid ones. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser that validates strings against the relative JSON pointer format. The macro generates a function that returns `{:ok, ...}` on success or `{:error, reason, ...}` on failure. ### Parameters #### Options - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~relative-json-pointer"`. ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Uri.html Creates a NimbleParsec parser that validates strings against the absolute URI format defined in RFC 3986. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser that validates if a given string is a valid absolute URI. The macro generates a function (defaulting to `~uri/1`) that returns `{:ok, ...}` on success or `{:error, reason, ...}` on failure. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the generated parser. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:~uri`. ``` -------------------------------- ### filter(opts \ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.IdnEmail.html A macro that creates a NimbleParsec parser for validating internationalized email addresses. It returns a tuple indicating success or failure based on the input string. ```APIDOC ## filter(opts \ []) ### Description Creates a `NimbleParsec` parser for validating internationalized email addresses (idn-email). The generated function returns `{:ok, ...}` for valid inputs or `{:error, reason, ...}` for invalid ones. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the macro. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~idn-email"`. ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.UriTemplate.html Creates a NimbleParsec parser function. The macro generates a function that validates a string against the URI template specification. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser function. The generated function returns `{:ok, ...}` if the input is a valid URI template, or `{:error, reason, ...}` if it is invalid. ### Parameters #### Options - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~uri-template"`. ``` -------------------------------- ### Compile JSONSchema to Elixir function Source: https://hexdocs.pm/exonerate/index.html Use Exonerate.function_from_string to generate a validation function at compile-time. The generated function returns :ok on success or {:error, keyword} on failure. ```elixir defmodule MyModule do require Exonerate Exonerate.function_from_string(:def, :function_name, """ { "type": "string" } "") end ``` -------------------------------- ### Lookup object filter module Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Retrieves the module associated with a specific object filter name. ```elixir @spec object_filter(String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.object_filter("properties") Exonerate.Filter.Properties iex> Exonerate.Modules.object_filter("required") Exonerate.Filter.Required ``` -------------------------------- ### Lookup combining filter module Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Retrieves the module associated with a specific combining filter name. ```elixir @spec combining(String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.combining("allOf") Exonerate.Combining.AllOf iex> Exonerate.Modules.combining("$ref") Exonerate.Combining.Ref iex> Exonerate.Modules.combining("dependentSchemas") Exonerate.Combining.DependentSchemas ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.UriReference.html Creates a NimbleParsec parser function that validates strings against URI reference standards. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser function. The generated function returns `{:ok, ...}` if the input is a valid URI reference, or `{:error, reason, ...}` if invalid. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the macro. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~uri-reference"`. ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Duration.html Creates a NimbleParsec parser function for duration strings. The generated function returns {:ok, ...} on success or {:error, reason, ...} on failure. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser function. The function will only be created once per module and is safe to call multiple times. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the parser. - **:name** (atom) - Optional - The name of the function to create. Defaults to :"~duration". ``` -------------------------------- ### filter(opts \ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Iri.html A macro that creates a NimbleParsec parser function (defaulting to ~iri/1) to validate strings against IRI format specifications. ```APIDOC ## filter(opts \ []) ### Description Creates a NimbleParsec parser function that validates if a given string is a valid IRI. The generated function returns `{:ok, ...}` on success or `{:error, reason, ...}` on failure. ### Parameters #### Options - **:name** (atom) - Optional - The name of the function to create. Defaults to :"~iri". ``` -------------------------------- ### List standard combining filters Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Returns a list of standard combining filter names, excluding 'dependentSchemas'. ```elixir @spec combining_filters() :: [String.t()] ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Regex.html Creates a NimbleParsec parser function (defaulting to ~regex/1) that validates strings against ECMA-262 regex standards. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser function. The function returns `{:ok, ...}` if the input string is a valid regex, or `{:error, reason, ...}` if it is not. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the macro. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~regex"`. ``` -------------------------------- ### filter(opts \\ []) Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Email.html Creates a NimbleParsec parser function for email validation. ```APIDOC ## filter(opts \\ []) ### Description Creates a `NimbleParsec` parser `~email/1`. This macro generates a function that returns `{:ok, ...}` if the input is a valid email, or `{:error, reason, ...}` if invalid. ### Parameters - **opts** (keyword list) - Optional - Configuration options for the macro. - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~email"`. ``` -------------------------------- ### Define t struct type Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Defines the structure of the Exonerate.Declaration type. ```elixir @type t() :: %Exonerate.Declaration{ degeneracy: :ok | :error | :unknown | nil, dependencies: [atom()] | nil, name: atom() | nil, opts: keyword() | Exonerate.Context.t() | nil, pointer: JsonPtr.t() | nil, resource: String.t() | nil, return_type: return_type() | nil } ``` -------------------------------- ### convert(value) Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Converts a given value into a Decimal type. ```APIDOC ## convert(value) ### Description Converts a value to Decimal. Returns {:ok, decimal} or {:error, reason}. ``` -------------------------------- ### Define return_type type Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Defines the possible return types for a declaration. ```elixir @type return_type() :: :ok | :ok_mapset | :ok_integer | :error | :unknown ``` -------------------------------- ### filter() Source: https://hexdocs.pm/exonerate/Exonerate.Formats.IriReference.html A macro that creates a NimbleParsec parser function for validating IRI references. It returns an :ok or :error tuple based on the validity of the input string. ```APIDOC ## filter() ### Description Creates a `NimbleParsec` parser function that validates strings against the IRI-reference format. The function returns `{:ok, ...}` for valid references or `{:error, reason, ...}` for invalid ones. ### Parameters - **:name** (atom) - Optional - The name of the function to create. Defaults to `:"~iri-reference"`. ``` -------------------------------- ### Add dependency to declaration Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Adds a dependency to an existing declaration. ```elixir @spec add_dependency(t(), atom()) :: t() ``` -------------------------------- ### Lookup JSON type module Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Retrieves the module associated with a specific JSON type name. ```elixir @spec type(String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.type("string") Exonerate.Type.String iex> Exonerate.Modules.type("object") Exonerate.Type.Object ``` -------------------------------- ### Lookup array filter module Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Retrieves the module associated with a specific array filter name. ```elixir @spec array_filter(String.t()) :: module() | nil ``` ```elixir iex> Exonerate.Modules.array_filter("items") Exonerate.Filter.Items iex> Exonerate.Modules.array_filter("uniqueItems") Exonerate.Filter.UniqueItems ``` -------------------------------- ### function_from_string/4 Source: https://hexdocs.pm/exonerate/index.html Generates a series of functions that validates a provided JSONSchema string. ```APIDOC ## function_from_string(type, function_name, schema_ast, opts \\ []) ### Description Generates a series of functions that validates a provided JSONSchema. The schema parameter must be a string literal. ### Parameters - **type** (atom) - The visibility of the generated function (e.g., :def, :defp). - **function_name** (atom) - The name of the generated validation function. - **schema_ast** (string) - The JSONSchema definition as a string literal. - **opts** (keyword list) - Optional configuration settings. ``` -------------------------------- ### Exonerate.function_from_string/3 Source: https://hexdocs.pm/exonerate/Exonerate.html Generates a validation function from a JSONSchema string at compile-time. ```APIDOC ## Exonerate.function_from_string(kind, name, schema) ### Description Generates a function that validates a BEAM JSON term against a provided JSONSchema string. The generated function returns `:ok` on success or `{:error, keyword}` on failure. ### Parameters - **kind** (atom) - Required - The function definition type (e.g., :def, :defp). - **name** (atom) - Required - The name of the generated function. - **schema** (string) - Required - A JSONSchema definition string. ### Return Value - **:ok** - Returned if the input term validates against the schema. - **{:error, keyword}** - Returned if validation fails. The keyword list contains `:instance_location`, `:schema_pointers`, and `:error_value`. ``` -------------------------------- ### Encode unicode charlists Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Punycode.html Converts a unicode charlist into its punycode representation. ```elixir @spec encode(charlist()) :: charlist() ``` ```elixir iex> Exonerate.Formats.Punycode.encode(~c"bücher") ~c"bcher-kva" iex> Exonerate.Formats.Punycode.encode(~c"München") ~c"Mnchen-3ya" ``` -------------------------------- ### Decode Punycode strings Source: https://hexdocs.pm/exonerate/Exonerate.Formats.Punycode.html Converts a punycode charlist to a unicode charlist. Raises ArgumentError for invalid input or restricted characters. ```elixir @spec decode(charlist()) :: charlist() ``` ```elixir iex> Exonerate.Formats.Punycode.decode(~c"bcher-kva") ~c"bücher" iex> Exonerate.Formats.Punycode.decode(~c"Mnchen-3ya") ~c"München" ``` -------------------------------- ### Define the Context struct type Source: https://hexdocs.pm/exonerate/Exonerate.Context.html The t() type defines the structure of the compilation state, including fields for tracking schema draft versions, pointers, and validation options. ```elixir @type t() :: %Exonerate.Context{ caller: Macro.Env.t() | nil, content_type: String.t() | nil, decimal: :all | keyword() | nil, decoders: list() | nil, draft: atom() | nil, dump: boolean() | nil, entrypoint: JsonPtr.t() | nil, format: atom() | keyword() | boolean() | nil, only: [String.t()] | nil, pointer: JsonPtr.t() | nil, resource: String.t() | nil, seen: MapSet.t() | nil, tracked: :object | :array | nil } ``` -------------------------------- ### Infer return type Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Determines the return type based on the current tracking mode. ```elixir @spec infer_return_type(t()) :: return_type() ``` -------------------------------- ### rem(a, b) Source: https://hexdocs.pm/exonerate/Exonerate.Decimal.html Computes the remainder of two Decimal values. ```APIDOC ## rem(a, b) ### Description Computes the remainder of a / b. ``` -------------------------------- ### Set degeneracy status Source: https://hexdocs.pm/exonerate/Exonerate.Declaration.html Sets the degeneracy status and updates the return type accordingly. ```elixir @spec with_degeneracy(t(), :ok | :error | :unknown) :: t() ``` -------------------------------- ### Check for standard combining filter Source: https://hexdocs.pm/exonerate/Exonerate.Modules.html Returns true if the filter is a standard combining filter. Note that 'dependentSchemas' returns false. ```elixir @spec combining?(String.t()) :: boolean() ``` -------------------------------- ### Constrain types in context Source: https://hexdocs.pm/exonerate/Exonerate.Context.html Updates the :only field by intersecting current constraints with new types. ```elixir @spec constrain_types(t(), [String.t()] | String.t()) :: t() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.