HTML::Tested::Value::PasswordBox - password input.


HTML-Tested documentation Contained in the HTML-Tested distribution.

Index


Code Index:

NAME

Top

HTML::Tested::Value::PasswordBox - password input.

DESCRIPTION

Top

Provides <input type="password" /> html tag.

METHODS

Top

$class->new($parent, $name, %opts)

Overloads HTML::Tested::Value new function to handle check_mismatch option.

OPTIONS

Top

check_mismatch

Checks mismatch between two passwords during validate phase. The parameter should be the name of another password box.

E.g. check_mismatch => 'another_password'.

On failure produces mismatch result for validate function.

AUTHOR

Top

Boris Sukholitko (boriss@gmail.com)

COPYRIGHT

Top


HTML-Tested documentation Contained in the HTML-Tested distribution.
use strict;
use warnings FATAL => 'all';

package HTML::Tested::Value::PasswordBox;
use base 'HTML::Tested::Value';

sub new {
	my ($class, $parent, $name, %opts) = @_;
	my $other = $opts{check_mismatch};
	push @{ $opts{constraints} }, [ mismatch => sub {
		my ($v, $root) = @_;
		return ($v // '') eq ($root->$other // '');
	} ] if $other;
	return $class->SUPER::new($parent, $name, %opts);
}

sub value_to_string {
	my ($self, $name, $val) = @_;
	return <<ENDS;
<input type="password" name="$name" id="$name" value="$val" />
ENDS
}

1;