github-actions-typing icon indicating copy to clipboard operation
github-actions-typing copied to clipboard

Validation rules for values

Open Vampire opened this issue 1 year ago • 0 comments

Sometimes it would be nice to be able to specify some additional validation rules that restrict the basic types further. For example if you use integer for a port value, it would be nice to be able to say min: 1 and max: 65535, or a regex for some string values.

So what I have in mind right now was exactly that. min and max for integer and float and regex or however called for string. enum, list, and boolean are probably already restricted enough per-se.

A consumer of the typing could then also generate according validation code. In some languages you can define a type directly like that, other languages have annotations with such validation information, yet other languages can generate runtime validation code.

When adding this, please keep in mind to clearly document which regex flavor has to be used by both sides.

Vampire avatar Aug 18 '24 20:08 Vampire