-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Validation does not happen as expected when the input AsyncApi spec have metacharacter '\d' in a pattern to match digits 0 to 9.
Issue seems to be because '\d' is not escaped correctly in the regex pattern string inside generated Validate() and hence considers it as character 'd' instead of digit.
Example:
Input AsyncApi spec have pattern: ^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$
Generated Validate() is below and it does not validate as expected,
void testasyncapi::schema::Date::Validate(const std::string& testValue)
{
std::regex regexPattern("^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$");
std::smatch regexMatch;
std::regex_match(testValue, regexMatch, regexPattern);
if (regexMatch.empty()) throw ::JsonSchemaException("The string value did not match the required regular expression pattern '^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$'");
}
Note: Tested only for metacharacter '\d'.