Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support every JSON Schema format for Draft 4 #780

Closed
jviotti opened this issue Jun 7, 2024 · 0 comments
Closed

Support every JSON Schema format for Draft 4 #780

jviotti opened this issue Jun 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jviotti
Copy link
Member

jviotti commented Jun 7, 2024

These are the ones that are missing right now:

// TODO: Enable all tests
{"date-time", "email", "hostname", "ipv6"});
, which should be implemented here:
auto compiler_draft4_validation_format(const SchemaCompilerContext &context)
-> SchemaCompilerTemplate {
if (!context.value.is_string()) {
return {};
}
// Regular expressions
static const std::string FORMAT_REGEX_IPV4{
"^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.(25[0-5]|2[0-4][0-"
"9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-"
"9][0-9]|[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$"};
const auto &format{context.value.to_string()};
if (format == "uri") {
return {make<SchemaCompilerAssertionStringType>(
context, SchemaCompilerValueStringType::URI,
type_condition(context, JSON::Type::String),
SchemaCompilerTargetType::Instance)};
}
#define COMPILE_FORMAT_REGEX(name, regular_expression) \
if (format == (name)) { \
return {make<SchemaCompilerAssertionRegex>( \
context, \
SchemaCompilerValueRegex{ \
std::regex{(regular_expression), std::regex::ECMAScript}, \
(regular_expression)}, \
type_condition(context, JSON::Type::String), \
SchemaCompilerTargetType::Instance)}; \
}
COMPILE_FORMAT_REGEX("ipv4", FORMAT_REGEX_IPV4)
#undef COMPILE_FORMAT_REGEX
return {};
}
.

Some of them are somewhat URI related, like hostname and ipv6, which might need to first be implemented in URI Kit, which has #710 as a requirement. For example, for ipv6 we likely want a full blown IPv6 parser in place?

@jviotti jviotti added enhancement New feature or request important and removed important labels Jun 7, 2024
@jviotti jviotti closed this as completed Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant