Skip to content

Linter: create rule to remove other validation keywords when enum is present based on type #1899

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

Karan-Palan
Copy link
Contributor

The rule removes:

  • String enum with numeric validation keywords
  • Numeric enum with string validation keywords
  • Object enum with mixed inapplicable validation keywords

@Karan-Palan Karan-Palan marked this pull request as ready for review July 28, 2025 09:41
@Karan-Palan
Copy link
Contributor Author

@jviotti any comments?

"minimum": 10,
"minLength": 2,
"minItems": 1,
"minProperties": 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your tests, mainly for older versions, are not considering the fact that many of these keywords do not exist in such older versions. For example, minProperties is only present in Draft 4.

The test works because in Draft 0, minProperties is not considered to be a keyword, therefore it applies to "any" type.

However, to make the tests cleaner, can you double check that you are not using any seemingly valid keyword on a Draft version that doesn't actually define it?

To test the above case, we can also have specific new tests that have a non-sense x-foo-bar keyword or something like that, and ensure it doesn't get removed

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

Successfully merging this pull request may close these issues.

2 participants