[Dbix-class] Column constraints
Carl Vincent
c.a.vincent at newcastle.ac.uk
Tue Apr 29 15:48:46 BST 2008
Hi Duncan,
There is also DBIx::Class::Validation - it allows you to do arbitrarily
complex validation on your content, and should cover creates as well as
updates.
Cheers
Carl
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Carl Vincent http://www.netskills.ac.uk/ (URL)
Systems Manager 0191 222 5003 (voice)
Netskills, Newcastle University 0191 222 5001 (fax)
Training - Accreditation - Consultancy - Development
>-----Original Message-----
>From: Duncan Ferguson [mailto:duncan.ferguson at altinity.com]
>Sent: 29 April 2008 14:20
>To: DBIx::Class user and developer list
>Subject: [Dbix-class] Column constraints
>
>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
>
>
>_______________________________________________
>List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>IRC: irc.perl.org#dbix-class
>SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>Searchable Archive: http://www.grokbase.com/group/dbix-
>class at lists.rawmode.org
More information about the DBIx-Class
mailing list