[Dbix-class] DBIx::Class::Validation doesn't seem to work

fREW Schmidt frioux at gmail.com
Tue Jul 7 22:31:43 GMT 2009


So this is really weird,

I am trying to use DBIx::Class::Validation and it never seems to run at
all!  (that is, the filters don't get run and defaults don't get set)

Also, if I use any of the closures (not commented out code) I get a compile
time error.  Does anyone see anything wrong with the following code?


> package ACD::Schema::Result::CustomerContact;
> use base DBIx::Class;
> use strict;
> use warnings;
> use Method::Signatures::Simple;
> use CLASS;
>
> CLASS->load_components(qw/Validation InflateColumn::Capitalize Core/);
>
> CLASS->table('CustomerContacts');
>
> CLASS->add_columns(qw/
>    id
>    customer_id
>    first_name
>    last_name
>    phone
>    fax
>    email
>    is_repair
>    is_accounts_payable
>    /);
>
>
> CLASS->add_columns(
>    first_name =3D> {
>       capitalization =3D> 'title_case'
>    },
>    last_name =3D> {
>       capitalization =3D> 'title_case'
>    },
> );
>
> CLASS->set_primary_key('id');
>
> CLASS->belongs_to('customer' =3D> 'ACD::Schema::Result::Customer',
> 'customer_id');
> CLASS->has_many('workorders' =3D> 'ACD::Schema::Result::WorkOrder',
> 'contact_id');
>
> use Data::FormValidator::Constraints qw(:closures);
> CLASS->validation(
>    module =3D> 'Data::FormValidator',
>    profile =3D> {
>       defaults =3D> {
>      is_repair =3D> 0,
>      is_accounts_payable =3D> 0,
>       },
>       constraint_methods =3D> {
>      #email      =3D> email(),
>      #first_name =3D> FV_min_length(1),
>      #last_name  =3D> FV_min_length(1),
>       },
>       filters =3D> ['trim'],
>       optional =3D> [qw{
>      first_name
>      last_name
>      email
>      phone
>      fax
>      is_repair
>      is_accounts_payable
>       }],
>       missing_optional_valid =3D> 1,
>    },
>    filters =3D> 1,
>    auto =3D> 1,
> );
>
> 1;
>


-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090707/6ec=
a4a91/attachment.htm


More information about the DBIx-Class mailing list