![]() |
![]()
| ![]() |
![]()
NAMEInterchange6::Schema::Component::Validation SYNOPSISpackage 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"); } } DESCRIPTIONThis 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(
In order to fail validation the "validation" method must throw an exception. METHODSvalidateCalled 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. insertOverload insert to call "validate" before insert is performed. updateOverload update to call "validate" before update is performed.
|