| HTML-Shakan documentation | Contained in the HTML-Shakan distribution. |
HTML::Shakan::Fields - fields
This module exports some functions, that generates a instance of HTML::Field::*.
If you want to know the details, please look the source :)
create a instance of HTML::Shakan::Input.
This is same as HTML::Shakan::Input->new(name => 'foo', type => 'text', @_);
TextField() + EMAIL_LOOSE constraint.
TextField() + HTTP_URL constraint
TextField() + UINT constraint
TextField() + INT constraint
define <input type="password" /> field
define <input type="fiel" /> field
FileField + FILE_MIME=image/* constraint
selector field.
date input field.
both field contains same value?
Tokuhiro Matsuno(tokuhirom)
use Params::Validate ':all';
| HTML-Shakan documentation | Contained in the HTML-Shakan distribution. |
package HTML::Shakan::Fields; use strict; use warnings; use parent 'Exporter'; use Carp (); our @EXPORT = qw( TextField EmailField URLField UIntField IntField PasswordField FileField ImageField ChoiceField DateField Duplication ); # DateTimeField # ImageField # TimeField sub _input { HTML::Shakan::Field::Input->new( @_ ); } sub TextField { _input(type => 'text', @_); } sub EmailField { TextField(@_)->add_constraint('EMAIL_LOOSE'); } sub URLField { TextField(@_)->add_constraint('HTTP_URL'); } sub UIntField { TextField(@_)->add_constraint('UINT'); } sub IntField { TextField(@_)->add_constraint('INT'); } sub PasswordField { _input(type => 'password', @_); } sub FileField { HTML::Shakan::Field::File->new(@_); } sub ImageField { FileField(@_)->add_constraint(['FILE_MIME' => qr{image/.+}]); } sub ChoiceField { HTML::Shakan::Field::Choice->new( @_ ); } sub DateField { HTML::Shakan::Field::Date->new( @_ ); } sub Duplication { my ($name, $f1, $f2) = @_; Carp::croak('missing args. Usage: Duplication(name, field1, field2)') unless @_ == 3; $f1->add_complex_constraint( +{ $name => [ $f1->name(), $f2->name() ] } => [ 'DUPLICATION' ] ); return ($f1, $f2); } 1; __END__