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
Parses a JSON schema const type into an JsonSchema.Types.ConstType
.
Returns true if the json subschema represents an const type.
Link to this section Functions
@spec parse( JsonSchema.Types.schemaNode(), URI.t(), URI.t() | nil, URI.t(), String.t() ) :: JsonSchema.Parser.ParserResult.t()
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