3#include <userver/chaotic/convert/to.hpp>
4#include <userver/chaotic/validators.hpp>
5#include <userver/formats/parse/to.hpp>
11template <
typename RawType,
typename... Validators>
12struct Primitive final {
16template <
typename Value,
typename RawType,
typename... Validators>
17RawType Parse(
const Value& value, formats::
parse::
To<Primitive<RawType, Validators...>>) {
18 auto result = value.
template As<RawType>();
19 chaotic::Validate<Validators...>(result, value);
23template <
typename Value,
typename RawType,
typename... Validators>
24Value Serialize(
const Primitive<RawType, Validators...>& ps, formats::
serialize::
To<Value>) {
25 return typename Value::Builder{ps.value}.ExtractValue();