#ifndef RFL_ALLOF_HPP_ #define RFL_ALLOF_HPP_ #include #include "Result.hpp" #include "parsing/schema/ValidationType.hpp" namespace rfl { /// Requires that all of the contraints C and Cs be true. template struct AllOf { template static rfl::Result validate(T _value) noexcept { return validate_impl(_value); } template static parsing::schema::ValidationType to_schema() { using ValidationType = parsing::schema::ValidationType; const auto types = std::vector({ C::template to_schema(), Cs::template to_schema()... }); return ValidationType { ValidationType::AllOf { .types_ = types } }; } private: template static rfl::Result validate_impl(T _value) noexcept { if constexpr (sizeof...(Tail) == 0) { return Head::validate(_value); } else { return Head::validate(_value).and_then(validate_impl); } } }; } // namespace rfl #endif