Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Suggestions for predefined enum sets #120

Open
chuwy opened this issue Dec 15, 2015 · 7 comments
Open

Suggestions for predefined enum sets #120

chuwy opened this issue Dec 15, 2015 · 7 comments

Comments

@chuwy
Copy link
Contributor

chuwy commented Dec 15, 2015

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.

  • Language codes
  • Timezones
  • HTML tags
  • Snowplow enriched event object properties
  • ...
@christoph-buente
Copy link

  • ISO 8601 datetime: https://en.wikipedia.org/wiki/ISO_8601
  • IP address regexp
  • Mac address regeexp
  • creditcard regexp
  • tracking number patterns for DHL, UPS, Fedex
  • email address regexp
  • barcodes like EAN, UPC or ISBN
  • weight units like mg, g, kg, t, lbs
  • length units like cm, m, km, mi, ft, in
  • time units like millisecond (ms), second (s), minute (m), hour (h), day (d), week (w), month (M), year, (y)

@christoph-buente
Copy link

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 :) ?

@chuwy
Copy link
Contributor Author

chuwy commented Mar 22, 2016

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.

@chuwy
Copy link
Contributor Author

chuwy commented Mar 22, 2016

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.

@christoph-buente
Copy link

Also fine with me. I did not use the web ui yet.

@chuwy
Copy link
Contributor Author

chuwy commented Mar 22, 2016

@christoph-buente
Copy link

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.

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

No branches or pull requests

2 participants