NAME

DBIx::Class::Valiant::Validator::Result - Verify a DBIC related result

SYNOPSIS

package Example::Schema::Result::Person;

use base 'Example::Schema::Result';

__PACKAGE__->load_components(qw/
  Valiant::Result
  Core
/);

__PACKAGE__->table("person");

__PACKAGE__->add_columns(
  id => { data_type => 'bigint', is_nullable => 0, is_auto_increment => 1 },
  username => { data_type => 'varchar', is_nullable => 0, size => 48 },
  first_name => { data_type => 'varchar', is_nullable => 0, size => 24 },
  last_name => { data_type => 'varchar', is_nullable => 0, size => 48 },
  password => {
    data_type => 'varchar',
    is_nullable => 0,
    size => 64,
  },
);

__PACKAGE__->might_have(
  profile =>
  'Example::Schema::Result::Profile',
  { 'foreign.person_id' => 'self.id' }
);

__PACKAGE__->validates(profile => (result=>+{validations=>1}, on=>'profile' ));

DESCRIPTION

Trigger validations on a related result and aggregates any errors as nested errors on the parent class.

NOTE: This gets added automatically for you if you setup accepts_nested on the parent object. So you shouldn't really ever need to use this code directly.

ATTRIBUTES

This validator supports the following attributes:

validations

Boolean. Default is 0 ('false'). Used to trigger validations on the related result.

Please keep in mind these errors will be localized to the associated object, not on the current object.

invalid_msg

String or translation tag of the error when the result is not valid. This will be in addition to any errors nested from the related result.

SHORTCUT FORM

This validator supports the follow shortcut forms:

validates attribute => ( result => 1, ... );

Which is the same as:

validates attribute => (
  result => {
    validations => 1,
  }
);

Which is a shortcut when you wish to run validations on the related rows

GLOBAL PARAMETERS

This validator supports all the standard shared parameters: if, unless, message, strict, allow_undef, allow_blank.

SEE ALSO

Valiant, Valiant::Validator, Valiant::Validator::Each.

AUTHOR

See Valiant

COPYRIGHT & LICENSE

See Valiant