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

How to interpret simple schemas that contains patternProperties #17

Open
jonaslagoni opened this issue Oct 8, 2021 · 2 comments
Open

Comments

@jonaslagoni
Copy link
Member

Similar to #12, with the very same side effects, we need to figure out how to interact with patternProperties. I only see the very same approach as outlined in #12, so let's use that issue as a baseline for this one.

@jdesrosiers
Copy link
Member

For the most part, I see this the same way I see addtionalProperties. It's a way to constrain how a type is allowed to be extended. However, it's more than that as well.

{
  "type": "object",
  "properties": {
    "i_value": { "maximum": 10 },
    "s_description": { "maxLength": 32 }
  },
  "patternProperties": {
    "^s_": { "type": "string" },
    "^i_": { "type": "integer" }
  }
}

In this case the type I would expect is this,

type Example = {
  i_value: number;
  s_description: string;
};

In this example patternProperties is not just constraining how it can be extended, it's also contributing to the types of a properties.

@jonaslagoni
Copy link
Member Author

In this example patternProperties is not just constraining how it can be extended

That is a good point 👀

Let's leave the discussion whether it needs to be included in #12 and follow the same behavior from there 🙂

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

2 participants