Hi all,
I needed a constraint to verify unique values in a db table using
DBIx::Class so I created
HTML::FormFu::Constraint::DBIC::Unique.
It may be useful to someone else so here it goes attached.

Carl, it has docs and tests in the case you want to had it to the svn repo.

SYNOPSIS:
          $form->stash->{schema} = $dbic_schema; # DBIC schema

          $form->element('text')
               ->name('email')
               ->constraint('DBIC::Unique')
               ->resultset('User')
               ;

          $form->stash->{context} = $c; # Catalyst context

          $form->element('text')
               ->name('email')
               ->constraint('DBIC::Unique')
               ->model('DBIC::User')
               ;

          $form->element('text')
               ->name('user')
               ->constraint('DBIC::Unique')
               ->model('DBIC')
               ->resultset('User')
               ;

          or in a config file:
          ---
          elements:
            - type: text
              name: email
              constraints:
                - Required
                - type: DBIC::Unique
                  model: DBIC::User
            - type: text
              name: user
              constraints:
                - Required
                - type: DBIC::Unique
                  model: DBIC::User
                  field: username



Cheers,
--
Jonas

Attachment: HTML-FormFu-Constraint-DBIC-Unique.tgz
Description: GNU Zip compressed data

_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget

Reply via email to