This document is explains how to write plugins for Data::Schema.
Data::Schema::Manual::Plugin - Writing plugins for Data::Schema
Any object can become a plugin as long as it satisfies these requirements.
1. It has a validator([$validator]) method to retrieve/set the validator property.
2. has handle_*() methods according to which functionalities it wants to supply.
The convention for handle_*() methods is to return 0 if fail, 1 if succeed, or -1 if decline. If a plugin decline to handle some event, the next plugin in the list will be tried.
This is called by DS in the validation process when encountering an unknown type to give a chance for plugins to load new types. Used for example by DSP::LoadSchema::YAMLFile to load schemas from YAML files.
This is for type handler. Called by DS's validate() to validate a type. See the implementation in, for example, DST::Base.
This is for type handler. Called by DST::Base's handle_type() method to allow subclass type handlers to do some checks before evaluating type attributes.
This is for type handler. Called by DST::Base's handle_type() method to allow subclass type handlers to do attribute checking. For example, if attribute min is encountered in the schema, handle_attr_min will be called.
Type handler can be thought of as yet another plugin. The differences are:
1. It is registered via $validator->register_type() instead of $validator->register_plugin().
2. It will only be involved in type checking during validation process. Specifically it will only handle:
handle_pre_check_attrs() handle_type() handle_attr_*()
3. You also need to supply cmp().
To use your new plugin, register it via:
Steven Haryanto <firstname.lastname@example.org>
This software is copyright (c) 2009 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.