JsonSchema.Parser.ConstParser (json_schema v0.6.0)

Copy Markdown View Source

Parse a JSON schema const type:

{
  "type": "string",
  "const": "This is a constant"
}

Into an JsonSchema.Types.ConstType.

Summary

Functions

Returns true if the json subschema represents an const type.

Functions

parse(schema_node, parent_id, id, path, name)

Parses a JSON schema const type into an JsonSchema.Types.ConstType.

type?(arg1)

@spec type?(JsonSchema.Types.schemaNode()) :: boolean()

Returns true if the json subschema represents an const type.

Examples

iex> type?(%{})
false

iex> type?(%{"const" => nil})
true

iex> type?(%{"const" => false})
true

iex> type?(%{"const" => "23.4"})
true

iex> type?(%{"const" => "This is a constant"})
true

iex> type?(%{"const" => %{"foo" => 42}})
true