You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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., thevalue
andidentifier_type
nodes in this example.However,
alias_method
can behave badly if a file isrequired
via two different paths -- the secondrequire
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 ifXML::MappingExtensions
would provide a safer validation alternative, e.g. some sort of node-definition wrapper that takes a validation block.The text was updated successfully, but these errors were encountered: