Skip to content

Wishlist: Object construction should fail if Moose attributes not correct #12

@mjemmeson

Description

@mjemmeson

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions