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

Add constraint checking for SIZE and INTEGER(l..h) #41

Open
odiferousmint opened this issue Jul 24, 2021 · 0 comments
Open

Add constraint checking for SIZE and INTEGER(l..h) #41

odiferousmint opened this issue Jul 24, 2021 · 0 comments

Comments

@odiferousmint
Copy link

odiferousmint commented Jul 24, 2021

Hello.

For example:

IA5String SIZE(0..10) would check if the length of string is between 0 and 10.
IA5String SIZE(10) would check if the length of string is exactly 10.
INTEGER(0..10) would check if the value is between 0 and 10.
INTEGER(10) would check if the value is exactly 10.

Now, my issue is what would happen if it fails? We will most likely know it as runtime, right? Would it be possible to catch this constraint error as an user of the library? If not, then I really have no idea how one would handle the bounds check errors besides just simply crashing. In any case, it should definitely should be possible to do this, just throw an error in the generated Java code in the decode method, so when the user of the library attempts to decode data that fits the specification but say, a value is higher than N, then it should throw a range error or something.

Easy-to-digest information about it here: https://stackoverflow.com/a/24238356/15088101


While we are at it, type checking would be pretty cool, too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant