Skip to content

Object properties defined by enum #818

Answered by gregsdennis
etinquis asked this question in Q&A
Discussion options

You must be logged in to vote

Right but the problem you're facing is that required takes an array of strings, not a schema, which means that you can't put the $ref there. This is why I designed data the way I did.

For what you want, you'd need to have locales.json be a file that just contains the array of values.

[
  "en",
  "fr"
]

Then you'd use data like this:

{
  "type": "object",
  "propertyNames": {
    "data": {
      "enum": "/locales.json"
    }
  },
  "data": {
    "required": "/locales.json"
  }
}

The way this works is that all of the values in data are replaced by the resolved values, which produces this (in memory):

{
  "type": "object",
  "propertyNames": {
    "data": {
      "enum": ["en", "fr"]
    }
 …

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@gregsdennis
Comment options

@etinquis
Comment options

@gregsdennis
Comment options

Answer selected by etinquis
@etinquis
Comment options

@gregsdennis
Comment options

@etinquis
Comment options

@jdesrosiers
Comment options

Comment options

You must be logged in to vote
3 replies
@etinquis
Comment options

@etinquis
Comment options

@etinquis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants