#pragma once #include #include #include #include namespace jvalidate::constraint { /** * @brief A constraint on the Array type. * Given an argument array, every element after applies_after_nth is * validated against subschema. applies_after_nth is made to be used in * conjunction with {@see TupleConstraint} and cannot be manually specified. * * https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.2 */ struct AdditionalItemsConstraint { schema::Node const * subschema; size_t applies_after_nth; }; /** * @brief A constraint on the Array type, that counts the number of elements * in the input array that match subschema and compares that number against * minimum and maximum. If minimum is unset, then it is equivalent to a minimum * of 1. If maximum is unset, then it is equivalent to a maximum of INF. As an * optimization, validation can be stopped after minimum matches if maximum is * unset. * * https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.3 * https://json-schema.org/draft/2020-12/json-schema-validation#section-6.4.4 * https://json-schema.org/draft/2020-12/json-schema-validation#section-6.4.5 */ struct ContainsConstraint { schema::Node const * subschema; std::optional minimum = std::nullopt; std::optional maximum = std::nullopt; }; /** * @brief A constraint on the Array type with the following characteristic(s): * @code{.cpp} * arg.size() <= value * @endcode * * https://json-schema.org/draft/2020-12/json-schema-validation#section-6.4.1 */ struct MaxItemsConstraint { int64_t value; }; /** * @brief A constraint on the Array type with the following characteristic(s): * @code{.cpp} * arg.size() >= value * @endcode * * https://json-schema.org/draft/2020-12/json-schema-validation#section-6.4.2 */ struct MinItemsConstraint { int64_t value; }; /** * @brief A constraint on the Array type. * Given an argument array, the Nth element of that Array is validated against * the Nth element of items. * * https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.1 */ struct TupleConstraint { std::vector items; }; /** * @brief A constraint on the Array type. * Given an argument array, every element which is not evaluated by another * schema {@see jvalidate::Status::Noop} will be validated against subschema. * * https://json-schema.org/draft/2020-12/json-schema-core#section-11.2 */ struct UnevaluatedItemsConstraint { schema::Node const * subschema; }; /** * @brief A constraint on the Array type that affirms that each element * of the array is unique. * * https://json-schema.org/draft/2020-12/json-schema-validation#section-6.4.3 */ struct UniqueItemsConstraint {}; }