Extra properties maxBytes #230
Unanswered
islombektoshev
asked this question in
Q&A
Replies: 1 comment
-
you have to create custom vocabulary for this. I have implemented it. you can see it: https://github.com/santhosh-tekuri/jsonschema/blob/boon/example_vocab_bytecount_test.go with the above vocabulary you have two new keywords: maxBytes, minBytes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
In most validation libraries, maxLength on a string counts Unicode code points, not bytes. However, in the database, storage limits are defined in terms of byte length (e.g., VARCHAR(255) refers to bytes, not characters). This mismatch can lead to runtime errors if multi-byte characters are used.
Question:
Is there a way to enforce string length validation based on byte size rather than code points? Specifically, I want to define a custom maxBytes constraint similar to maxLength, but I'm not sure how to implement or integrate that. Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions