-
Notifications
You must be signed in to change notification settings - Fork 31
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
Inventory classification change - fix birthPeriod validation #334
Inventory classification change - fix birthPeriod validation #334
Conversation
InventoryClassification birth period previously specified the birth period as an (RFC3339) icarDateType. But in fact, per the description it is an ISO8601 interval. Changed the type to string, and added a pattern which matches a simple ISO8601 date interval (no time component) and the year and month options as per the description.
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.
No comment from my side
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.
- the 2 parts differ. whereas the first one is very flexible, the second one is fixed to YYYY-MM-DDZ
- the first part offers the possibility to insert YYYY-99, e.g. by defining [0-9]{2} as month
- Is the second part really optional? I think not. The separator as well.
Having tested this in https://regex101.com/ there are three effective captures:
So I think the optionality is right, but would be willing to accept corrections :-)
|
Tightened the regex to make it clearer that dates are intended (as per description) but this is not perfect, its just simple and fast.
birthPeriod was previously specified as an icarDateType, which is half-right, because it is a date range.
Most validators interpret "format": "date" as an RFC3339 date, which does not allow for ranges.
Instead I have changed its type to string, and defined a pattern with a regex. If this is too complex we can ditch the regex and simply make it a string with the current description.