Lyo Kato

NAME

FormValidator::Simple::Plugin::DBIC::Unique - unique check for DBIC

SYNOPSIS

    use FormValidator::Simple qw/DBIC::Unique/;

    # check single column
    FormValidator::Simple->check( $q => [
        name => [ [qw/DBIC_UNIQUE TableClass name/] ],
    ] );

    # check multiple columns
    FormValidator::Simple->check( $q => [
        { unique => [qw/name email/] } => [ [qw/DBIC_UNIQUE TableClass name mail/] ],
    ] );

    # check multiple columns including '!=' check
    # set "!" as prefix for key-name
    FormValidator::Simple->check( $q => [
        { unique => [qw/id name email/] } => [ [qw/DBIC_UNIQUE Table !id name mail/] ]
    ] );


    # when the class name is too long...
    FormValidator::Simple->check( $q => [
        name => [ [qw/DBIC_UNIQUE MyProj::Model::User name/] ],
    ] );

    # you can set cdbi_base_class in option.
    FormValidator::Simple->set_option( dbic_base_class => 'MyProj::Model' );
    FormValidator::Simple->check( $q => [
        name => [ [qw/DBIC_UNIQUE User name/] ],
    ] );

    # you also can pass resultset object.

    # in catalyst application,
    FormValidator::Simple->check( $q => [
        name => [ ['DBIC_UNIQUE', $c->model('Schema::User'), 'username' ] ],
    ] );
    
    # in case you use schema,
    FormValidator::Simple->check( $q => [
        name => [ [ 'DBIC_UNIQUE', $c->model('Schema')->resultset('User'), 'username' ] ],
    ] );
    
    FormValidator::Simple->check( $q => [
        name => [ [ 'DBIC_UNIQUE', $schema->resultset('User'), 'username' ] ],
    ] );

DESCRIPTION

This module is a plugin for FormValidator::Simple. This provides you a validation for unique check with DBIC table class.

SEE ALSO

FormValidator::Simple

AUTHOR

Lyo Kato <lyo.kato@gmail.com>

Basic Idea: Masahiro Nagano <kazeburo@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Lyo Kato

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.