View Source JsonSchema.Parser.ConstParser (json_schema v0.4.0)

Parse a JSON schema const type:

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

Into an JsonSchema.Types.ConstType.

Link to this section Summary

Functions

Returns true if the json subschema represents an const type.

Link to this section Functions

Link to this function

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

View Source

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

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

Returns true if the json subschema represents an const type.

examples

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