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

Schema def prop allow support definition objects #41

Closed
ksafranski opened this issue Mar 31, 2016 · 0 comments
Closed

Schema def prop allow support definition objects #41

ksafranski opened this issue Mar 31, 2016 · 0 comments
Assignees

Comments

@ksafranski
Copy link
Contributor

Since a schema property can be shared it can create a single-source for configurations. As such, one area where this applies well is allow; it's accepted values and any metadata associated with those, for example:

status: { type: 'string', allow: [ 'prog', 'comp', 'arch' ] }

Maintaining enums in a separate location for the allow "keys" ([ 'prog', 'comp', 'arch' ]) presents the challenge of maintaining this in multiple locations.

Proposed Solution

Currently allow supports either a string or an array. The proposal would be to expand this to also allow an object:

status: { type: 'string', allow: { 'prog': 'in progress', 'comp': 'completed', 'arch': 'archived' } }

The above would simply process to allow the keys of the object as values, but the whole object could then be maintained in a lib (or in the model) and shared easily.

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