-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix: string date format validation #484
Conversation
Please make sure that this test works as expected. fast-json-stringify/test/date.test.js Line 492 in e083ca6
|
} | ||
return this.asString(date) | ||
throw new Error(`The value "${date}" cannot be converted to a date-time.`) |
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.
What if I passed a string that fulfill date-time
, date
, time
?
It seems like it only accept Date
object after this change.
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.
If you pass a string it will be stringified in the asString
method.
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.
return validateTimeFormat(date) | ||
} | ||
return false | ||
keyword: 'fjs_type', |
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.
keyword: 'fjs_type', | |
keyword: 'fjs_date_type', |
I think we should try not to change this.
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.
@mcollina I agree, but it is a completely different meaning of this property now. It's not a date format anymore. It describes how ajv should validate custom type at all. For example, for string type, there would be not only the Date object validation but also Regexp objects and some other exceptions.
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
Checklist
npm run test
andnpm run benchmark
and the Code of conduct