__PACKAGE__->table(
"state"
);
__PACKAGE__->add_columns(
id
=> {
data_type
=>
'integer'
,
is_nullable
=> 0,
is_auto_increment
=> 1 },
name
=> {
data_type
=>
'varchar'
,
is_nullable
=> 0,
size
=>
'24'
},
abbreviation
=> {
data_type
=>
'varchar'
,
is_nullable
=> 0,
size
=>
'24'
},
);
__PACKAGE__->set_primary_key(
"id"
);
__PACKAGE__->add_unique_constraint([
'name'
]);
__PACKAGE__->add_unique_constraint([
'abbreviation'
]);
__PACKAGE__->has_many(
profiles
=>
'Example::Schema::Result::Profile'
,
{
'foreign.state_id'
=>
'self.id'
}
);
sub
isa_state_name {
my
(
$self
,
$attribute_name
,
$value
) =
@_
;
return
if
$self
->result_source->resultset->find({
name
=>
$value
});
$self
->errors->add(
$attribute_name
, \
'{{value}} is not a State name'
);
}
1;