-
Notifications
You must be signed in to change notification settings - Fork 52
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
Vc 2.0 time props #158
Vc 2.0 time props #158
Conversation
d9d7ba4
to
dcecf7b
Compare
f487795
to
4a62c7b
Compare
lib/helpers.js
Outdated
@@ -10,7 +10,16 @@ export const { | |||
CONTEXT_URL: CREDENTIALS_CONTEXT_V2_URL | |||
} | |||
} = credentialsContextV2; | |||
// Z and T can be lowercase | |||
// RFC3339 regex | |||
export const dateRegex = new RegExp('^(\\d{4})-(0[1-9]|1[0-2])-' + |
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.
Should this match XML Schema 1.1 dateTimeStamp? https://w3c.github.io/vc-data-model/#example-regular-expression-to-detect-a-valid-xml-schema-1-1-part-2-datetimestamp
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 year validation in that RegExp is more strict than mine and it also handles years larger than 4 numbers so that seems like an advantage. it also has a different validator for T or Z so yeah I'll adapt it to this lib today.
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 VCDM spec says:
To avoid doubt, the regular expression in [XMLSCHEMA11-2] is the normative definition.
Sadly, the XML Schema 1.1 spec lacks a handy copy/paste-able regular expression. I will note that that spec does point out that year
is simply an integer--and doesn't denote any limit on number of characters.
At the very least, we should use the regular expression called out in the VCDM spec as example 14. However, even the VCDM calls that out as "minimal":
The regular expression shown below (minus the whitespace included here for readability), is often adequate when processing library-generated dates and times on modern systems.
So...if we can find something more accurate/complete, we should...but lets at least start from what's in the VCDM spec rather than something custom.
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.
Addressed here: 80d30d7
lib/helpers.js
Outdated
@@ -10,7 +10,16 @@ export const { | |||
CONTEXT_URL: CREDENTIALS_CONTEXT_V2_URL | |||
} | |||
} = credentialsContextV2; | |||
// Z and T can be lowercase | |||
// RFC3339 regex | |||
export const dateRegex = new RegExp('^(\\d{4})-(0[1-9]|1[0-2])-' + |
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 VCDM spec says:
To avoid doubt, the regular expression in [XMLSCHEMA11-2] is the normative definition.
Sadly, the XML Schema 1.1 spec lacks a handy copy/paste-able regular expression. I will note that that spec does point out that year
is simply an integer--and doesn't denote any limit on number of characters.
At the very least, we should use the regular expression called out in the VCDM spec as example 14. However, even the VCDM calls that out as "minimal":
The regular expression shown below (minus the whitespace included here for readability), is often adequate when processing library-generated dates and times on modern systems.
So...if we can find something more accurate/complete, we should...but lets at least start from what's in the VCDM spec rather than something custom.
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.
Thanks!
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.
Small change to hopefully reduce confusion down the road.
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.
Not sure about removing the milliseconds. Other folks using JS to generate these date strings won't bother.
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.
Works for me.
@aljones15 Is the PR this one is merging into ready for review? I suggest reviewing the other PR before merging this one into it. If it's ready for review, please mark it as such. Thanks. |
dcecf7b
to
fd12342
Compare
194de55
to
f8099c3
Compare
fc2a605
to
02c9701
Compare
f8099c3
to
dbaf8c8
Compare
Implements VC 2.0
validUntil
andvalidFrom
feature and tests.CI is failing in node 14.
Addresses: #102