- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Description
XML::Mapping creates setters for all nodes. In general, these setters don't provide validation. The obvious way to provide validation is to create a private alias for the setter, and redefine the public setter to validate before calling the private one, e.g., the value and identifier_type nodes in this example.
However, alias_method can behave badly if a file is required via two different paths -- the second require will hide the original generated setter completely, instead aliasing the redefined public setter. When the redefined public setter attempts to call the private setter, it instead calls itself, resulting in a stack overflow as in datacite-mapping #1.
This is a general problem with alias_method, but since adding validation to setters is such a common use case in XML mapping, it would be nice if XML::MappingExtensions would provide a safer validation alternative, e.g. some sort of node-definition wrapper that takes a validation block.