Skip to content
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

Invalid date not triggering an error #13

Open
theonegri opened this issue Dec 21, 2020 · 0 comments
Open

Invalid date not triggering an error #13

theonegri opened this issue Dec 21, 2020 · 0 comments

Comments

@theonegri
Copy link

theonegri commented Dec 21, 2020

Hello.

I'm currently investigating a potential issue with invalid dates not getting caught in this block
I have the following variables :
v = "2011-11-41"(an invalid date)
primitive_meta = {"type"=>"string", "regex"=>"-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1]))?)?"}
datatype = "date"

This condition(primitive_meta['regex'] && primitive_meta['type'] != 'number') returns true because primitive_meta['type'] is a string.
And (v =~ Regexp.new(primitive_meta['regex'])) returns 0 .
So on the following line match.nil? returns false meaning that the date is correct.

I don't exactly understand why we have checking for the number (type because this line FHIR::STU3.primitive?(datatype: datatype, value: v) would actually work.) so I don't really know what the best solution could be.

Thanks

@theonegri theonegri changed the title Invalid date note triggering an error Invalid date not triggering an error Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant