[Dbix-class] Column constraints
Duncan Ferguson
duncan.ferguson at altinity.com
Tue Apr 29 14:20:11 BST 2008
Hiya,
I am using DBIx-Class-0.08010 and I want to constrain the contents of
a column, i.e. a column 'name' can only contain text starting with [a-
z]. In Class::DBI I could use
__PACKAGE__->constrain_column(name => qr/^[a-z].*$/);
I have tried to overload the accessor in DBIC and this works on
existing items, but the accessor is not called when an object is created
$schema->resultset("Names")->create({ name => "4name" });
What is the best way to achieve this with current code? On IRC it was
suggested I could use Moose and MooseX::Types (any examples on the
'net of using Moose with DBIx::Class? Couldn't find any) or create a
custom resultset and tell my table class to use that via __PACKAGE__-
>resultset_class().
I am using $schema->deploy to set up my database (so I can version it
later) so i wouldn't want to break usage of this.
TIA
Duncs
More information about the DBIx-Class
mailing list