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
Wishlist: Object construction should fail if Moose attributes not correct #12
Comments
@mjemmeson I'm sorry for the extremely long wait. The last question I can answer first. The reason why everything is lazy-evaluated is because it's just what I'm used to do, so that memory and CPU resources are not used for anything unless it is needed. Back to the first question, what do you mean by "parsing the XML satisfactorily"? Does that just mean that the XML is well-formed, or that it also confirms to a schema or anything else? Right now the only test which is performed on the XML is that it is well-formed, and that is done by XML::LibXML when it constructs the DOM tree used for the xpath queries. Can you explain what kind of behavior you'd like to be able to support with this |
Hi, I think there are two issues here actually:
Maybe a possible solution is to provide a method which calls the lazy document builder in XML::Rabbit::Role::Document
Another would be to check at construction time, something like
I hope that is a bit clearer. thanks again, |
In GitHub issue #12 it is argued that there should be a way to check that the XML data passed into the constructor is well-formed. With this feature it should now be possible.
@mjemmeson I've added a branch that add a method to root classes called I'm wondering if it is better to return a boolean value (as I've implemented now) or the underlying XML::LibXML document ( For your second issue I'm wondering how we could do this in the best way. The |
@mjemmeson One thing I forgot to mention in the previous comment is that the |
Hi,
It would be nice if instead of returning an object in the event of failure to parse the XML satisfactorily, Moose arguments like 'required' were honoured.
Looking at the code, using "required" doesn't seem to be an option at present - because of the use of 'default'. With a little playing it was possible to get a mismatched types error (e.g. "Attribute (method) does not pass the type constraint because: Validation failed for 'Str' with value undef") but nothing better.
Ideally, setting "required => 1" should cause construction to fail if the node isn't found. I was wondering if you had had any thoughts on this?
thanks,
Michael
edit - after looking further (to see if I could get it to die on invalid XML) it looks like the document parsing is lazy - is there a reason for that?
The text was updated successfully, but these errors were encountered: