Pattern matching checks on string types and bounds settings on integer and number types. #2648
fairbanksscales-dev
started this conversation in
Ideas
Replies: 0 comments
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.
Uh oh!
There was an error while loading. Please reload this page.
-
When defining an alias or field annotation with allowed values for such types, I would like to be able to define a pattern that checks string literals that are known before runtime for correctness. The pattern matching algorithm can be the built in Lua one or could be a full Perl like regex implementation. The point of it would be to ensure that the string literals properly match on that pattern. You could make a whitelist pattern list where it must match one or more of the patterns to not get flagged and a blacklist pattern list where if one of them matches it gets flagged as a potential issue and allow comments after each pattern to enable the developer who made the pattern that is matching or not matching explain their intent behind the pattern check. This of course can only be ran against known string literals that are in code. You could also make a priority value settable on the patterns so that if one white list pattern has a higher priority than a blacklist pattern and both are matching on the string literal then the blacklisted pattern is ignored or a different type of error message is displayed in the IDE like error vs warning.
I would like to also have the ability when defining the allowed values for an alias or field to be able to make a range statement like integer 0-31 for all integers between 0 and 31 and including 0 and 31. This could apply to number type as well so that number 0.0-31.0 would check all floating point literals. This does get tricky as floating point is really the underlying number type in Lua and delineating between the two is difficult.
Beta Was this translation helpful? Give feedback.
All reactions