Interchange6::Schema::Component::Validation
package My::Result; __PACKAGE__->load_components(qw( +Interchange6::Schema::Component::Validation )); sub validate { my $self = shift; my $schema = $self->result_source->schema; unless ( $self->some_column =~ /magic/ ) { $schema->throw_exception("some_column does not contain magic"); } }
This component allows validation of row attributes to be deferred until other components in the stack have been called. For example you might want to have the TimeStamp component called before validation so that datetime columns with set_on_create are defined before validation occurs. In this case your local_components call might look like;
__PACKAGE__->load_components( qw(TimeStamp +Interchange6::Schema::Component::Validation) );
In order to fail validation the "validation" method must throw an exception.
Called before insert or update action. Method should be overloaded by class which load this component. Validation failures should result in DBIx::Class::Schema::throw_exception being called.
Overload insert to call "validate" before insert is performed.
Overload update to call "validate" before update is performed.
To install Interchange6::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Interchange6::Schema
CPAN shell
perl -MCPAN -e shell install Interchange6::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.