-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add configurable rule for strict string definitions #34
Conversation
@adamaltman a node cannot be used twice in the
There are several options to this, e.g. you can define a custom function (in a plugin) which will combine the two assertions into one, or you can try 'moving' one of the checks into the actual assertion (depends on the behaviour you're trying to achieve). What the rule should do? |
It should make sure all strings have |
Could you try if something like this works for you? rule/string-schemas:
where:
- subject:
type: Schema
property: type
assertions:
const: string
subject:
type: Schema
assertions:
requireAny:
- minLength
- maxLength
- enum
mutuallyRequired:
- minLength
- maxLength |
This does work. (Maybe I'll some more test cases first before we declare victory. 😆 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor comment.
subject: | ||
type: Schema | ||
where: | ||
- subject: | ||
type: Schema | ||
property: type | ||
assertions: | ||
const: string | ||
assertions: | ||
requireAny: | ||
- minLength | ||
- maxLength | ||
- enum | ||
mutuallyRequired: | ||
- minLength | ||
- maxLength |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Albeit it's correct, the opposite order seems more natural to me. I think it's easier to read if the top-level subject
and assertions
are grouped together and the where
lies above or or below. What do you think?
Co-authored-by: Andrew Tatomyr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition!
Strict string length definitions
Make sure that there is a min and max length defined on every string except for enums.
Resolved
See the history of this rule
I need help with this rule because it doesn't work as expected.To execute the rule I need the same object in two where clauses, and our documentation is unclear if this is allowed or not.
https://redocly.com/docs/cli/rules/configurable-rules/#where-object
It doesn't state if you can use the same node twice. If I can't, how do I accomplish this rule?