Join GitHub today
Invalid date should fail to parse #50
Reported on the mailing list here by Joseph Althman: https://groups.google.com/forum/#!topic/hapi-fhir/MT6eDnuzItk
The following date field parses successfully even though it's invalid:
This should probably be an exception flat out.
..where the first takes a type which is appropriate to the primitive in question (java.util.Date for DateTimeDt, java.math.BigDecimal for DecimalDt, etc.) and the second just takes a String.
The behaviour in all of these types right now is that the parser/encoders use the get/setValueAsString methods, but these methods actually all convert to the appropriate type right away. If we deferred that conversion until the first time getValue() was called, we would get exactly the behaviour you're describing (the weird date would be encoded back in it's weird form to XML, and the validator could catch it)
I see one pro and one con to this approach:
I think over the course of writing this I went from not liking this idea to liking it. :)