-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat(ibm-use-date-based-format): introduce new validation rule #706
base: main
Are you sure you want to change the base?
Conversation
Docs are updated 👍 |
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.
PR looks great!
I just had one small suggestion for date-based-utils.js
.
d2d9794
to
a6b5ee1
Compare
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.
LGTM!
53d9653
to
0e16a95
Compare
The comment noted that the rule was using the resolved API definition, when it was, in fact, using the unresolved definition. This wasn't a bug - the rule doesn't look at any locations that might include references - but the documentation was wrong and misleading. This commit fixes that. Signed-off-by: Dustin Popp <[email protected]>
I think this file was added around the same time that the tests were re-organized into folders. It must have been overlooked during the changes. This commit moves it to the right spot and corrects the copyright statement (this file was created in 2024). Signed-off-by: Dustin Popp <[email protected]>
This commit introduces the new 'ibm-use-date-based-format' rule, which will heuristically verify that schemas, with either a name or an example value indicating a date-based logical type, be strings and use either "date" or "date-time" as the format. Signed-off-by: Dustin Popp <[email protected]> Co-authored-by: Dan Hudlow <[email protected]>
7bac905
to
9b07fb6
Compare
// parses the object, looking for the value at that path. If it finds one, | ||
// the value will be returned. If not, the function will return `undefined`. | ||
function getObjectValueAtPath(obj, pathToValue) { | ||
return pathToValue.reduce((value, field) => value[field], obj); |
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.
I think this is needed to keep this safe in the case that an undefined property is encountered before the last element of the path.
return pathToValue.reduce((value, field) => value[field], obj); | |
return pathToValue.reduce((value, field) => value?.[field], obj); |
PR summary
This commit introduces the new 'ibm-use-date-based-format' rule,
which will heuristically verify that schemas, with either a name
or an example value indicating a date-based logical type, be
strings and use either "date" or "date-time" as the format.
PR Checklist
General checklist
Please make sure that your PR fulfills the following requirements:
.secrets.baseline
has been updated as needednpm run generate-utilities-docs
has been run if any files inpackages/utilities/src
have been updatedChecklist for adding a new validation rule: