-
Notifications
You must be signed in to change notification settings - Fork 20
Suggestions for predefined enum sets #120
Comments
|
Can the enum also be a pattern ("pattern" : "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$") or a format ("format" : "ipv4") or is it exclusively for an array of representations as allowed values? And why is the format: "ipv4" not a regexp as well :) ? |
Unfortunately, enum is always just an array of allowed values (not just strings, but numbers, objects etc are allowed as well). It is defined like that in JSON Schema specification. Same for ipv4: we derive it as format just because it is defined that way in specs. I think creators of JSON Schema have reasons to not use regex property for IPv4 (readability may be? I'm going to find out). But idea with custom regexes can be good as your idea with mappings or this one with enum sets. It can be especially good because theoretically it can allow us to derive precise maxLength for strings. |
I really like all ideas with custom logic: mappings, regexes, etc. One problem with it is just it seems not very on demand among Schema Guru users and relatively hard to implement. I think it could be much more useful if it will be embedded in Web UI. |
Also fine with me. I did not use the web ui yet. |
Ok, i read up on the JSON schema and saw there is support for the ISO 8601 aka RFC 3339 already. But for some reason the email format is not correctly detected. So i think #143 is still valid, to pass in any mapping between a field name and a enum/type/format definition. |
There are plenty more options for implemented in 0.4.0 --enum-sets feature. Here we're collecting them to decide what we can add.
One important restriction is that we must have single source of truth for proposed enumerations, like ISO, source code or something similar, that's why "colors" doesn't seem appropriate.
The text was updated successfully, but these errors were encountered: