Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow passing Email::Valid params to Email field

  • Loading branch information...
commit d8ae8b607e0bf171d49a69f7199ebe0849d8e2aa 1 parent da84d66
@gshank authored
Showing with 21 additions and 1 deletion.
  1. +9 −1 lib/HTML/FormHandler/Field/Email.pm
  2. +12 −0 xt/email.t
View
10 lib/HTML/FormHandler/Field/Email.pm
@@ -11,6 +11,11 @@ our $class_messages = {
};
has '+html5_type_attr' => ( default => 'email' );
+has 'email_valid_params' => (
+ is => 'rw',
+ isa => 'HashRef',
+);
+
sub get_class_messages {
my $self = shift;
return {
@@ -27,7 +32,10 @@ apply(
{
check => sub {
my ( $value, $field ) = @_;
- my $checked = Email::Valid->address( $value );
+ my $checked = Email::Valid->address(
+ -address => $value,
+ %{ $field->email_valid_params || {} },
+ );
$field->value($checked)
if $checked;
},
View
12 xt/email.t
@@ -35,3 +35,15 @@ $field->_set_input('someuser@example.com');
$field->validate_field;
ok( !$field->has_errors, 'Test for errors 3' );
+{
+ package MyApp::Form::Test;
+ use HTML::FormHandler::Moose;
+ extends 'HTML::FormHandler';
+
+ has_field 'foo';
+ has_field 'email' => (
+ type => 'Email',
+ email_valid_params => { -mxcheck => 1 },
+ );
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.