Closed seth-shaw-unlv closed 3 years ago
Well, I guess I can simply bypass the factory SaneParser and instantiate a Parser myself...
Making the exception message available in ParsingResult makes sense. https://github.com/ProfessionalWiki/EDTF/blob/master/src/PackagePrivate/SaneParser.php#L18-L19
While you could use Parser directly, that thing is a handful to deal with, and it is not part of the public interface of the library, so you'd not be able to upgrade minor versions safely.
Thanks. I'll work with the Parser directly for validation for the time being but then switch back to using the factory once we have a version where I can get those messages.
@seth-shaw-unlv master and ~1.3.0 (not tagged yet) now support access to the error message in ParsingResult
I can see reading through the code that the validator is generating messages about why a provided string is considered an invalid ETDF... however, the ParsingResult I can get from the SaneParser and Validator available from the EDTF factory doesn't even get a copy of them; instead it only gives us isValid() based on the existence of an EdtfValue (or lack thereof) from the SaneParser which swallows the InvalidArgumentException.
I need to give my users some clue as to why I'm rejecting the EDTF string they entered. Could we get those messages propagated to the ParsingResult? Or, failing that, as a developer I would rather catch the InvalidArgumentException than have it swallowed and reduced to a boolean response.