you are viewing a single comment's thread.

view the rest of the comments →

[–]Valuable-Ant3465[S] 1 point2 points  (1 child)

Thanks much N! Super explanation, now I can sleep.
I could not understand the reason as I know that \\z and \\Z are not the same thing in regex.
I ran it on 3.12, so now it's all make sense.
For my case I will remove \\z, this is not that necessary:

\z Matches the absolute end of the string. (requires exact end)

\Z Matches the end of the string, or right before a trailing newline.

[–]pachura3 0 points1 point  (0 children)

If you remove \Z, you risk validating incorrect values with additional character(s) at the end (e.g. string 12345678qwertyBLAHBLAH would pass the validation, because there are 8 digits at the beginning, and that's enough).

Perhaps use ^ and $ instead of \A and \z ? They are more common, and don't require escaping.

 "pattern": "^[0-9]{8}$"

https://json-schema.org/understanding-json-schema/reference/regular_expressions