class JSONSchema::FluentObjectValidator
- JSONSchema::FluentObjectValidator
- Reference
- Object
Overview
A fluent API for creating instances of JSONSchema::ObjectValidator
.
Included Modules
Defined in:
fluent.crInstance Method Summary
-
#additional_properties(v : Validator)
Set the validator for any additional properties not in the properties definition.
-
#dependent_required(name : String, values : Array(String))
Set a single dependent required property by name.
-
#dependent_required(value : Hash(String, Array(String)))
Set the list of dependent required properties.
-
#dependent_schema(name : String, &)
Set a single dependent schema property by name.
-
#disable_additional_properties
Set the constraint for disabling additional properties.
-
#max_properties(value : Int32)
Set a validator for the minimum number of properties that must be on the object.
-
#min_properties(value : Int32)
Set a validator for the minimum number of properties that must be on the object.
-
#pattern_prop(pattern : Regex, v : Validator)
Set the validator for a given
Regex
. -
#prop(name : String, v : Validator)
Set the validator for a property by name.
-
#property_names(v : Validator)
Set a validator for all property names.
-
#required(*properties)
Set the list of required properties as any number of strings.
- #validator : JSONSchema::ObjectValidator
Instance methods inherited from module JSONSchema::FluentValidatorGenericProperties
all_of(*children)
all_of,
any_of(*children)
any_of,
enum_list(*values)
enum_list,
not(*children)
not,
one_of(*children)
one_of
Instance Method Detail
Set the validator for any additional properties not in the properties definition. See Additional Properties.
Set a single dependent required property by name. See Dependent Required.
validator = JSONSchema.fluent.object do
dependent_required "creditCard", ["billingAddress"]
dependent_required "couponCode", ["source"]
end
Set the list of dependent required properties. See Dependent Required.
validator = JSONSchema.fluent.object do
dependent_required({
"creditCard" => ["billingAddress"],
})
end
Set a single dependent schema property by name. See Dependent Schemas.
This method accepts a block, unlike many fluent methods. Since we know an #dependent_schema
value must be
a JSONSchema::ObjectValidator
, we accept a block and use JSONSchema::FluentObjectValidator
as the receiver.
# Validates that "prop1" is both present and a number, given "prop1" is present
validator = JSONSchema.fluent.object do
dependent_schema "prop1" do
prop "prop2", JSONSchema.fluent.number
required "prop2"
end
end
Set the constraint for disabling additional properties. See Addiitonal Properties.
Set a validator for the minimum number of properties that must be on the object.
Set a validator for the minimum number of properties that must be on the object.
Set the validator for a given Regex
. See Pattern Properties.
Set the validator for a property by name. This method is named #prop
to not conflict with the global property
macro.
Set a validator for all property names. See Property names.
Set the list of required properties as any number of strings.
validator = JSONSchema.fluent.object do
required "name", "age"
end