View Source ConfluentSchema (confluent_schema v0.1.0)

Provides cache and validation for confluent schemas.

Link to this section Summary

Functions

Validates the payload against the schema for the given subject.

Link to this section Types

@type errors() :: [{message :: binary(), path :: binary()}]

Link to this section Functions

Link to this function

validate(payload, subject)

View Source
@spec validate(map(), binary()) ::
  {:ok, map()} | {:error, :not_found} | {:error, errors()} | no_return()

Validates the payload against the schema for the given subject.

examples

Examples

iex> ConfluentSchema.validate("a string example", "subject")
{:ok, "a string example"}

iex> ConfluentSchema.validate("a string example", "unknown-subject")
{:error, :not_found}

iex> ConfluentSchema.validate(123, "subject")
{:error, [{"Type mismatch. Expected String but got Integer.", "#"}]}