do not include .git directory
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / Mutable / MatchingPasswords.pm
CommitLineData
24185a7d 1package Reaction::UI::ViewPort::Field::Mutable::MatchingPasswords;
2
3use Reaction::Class;
81393881 4use namespace::clean -except => [ qw(meta) ];
7b5e71ad 5use MooseX::Types::Moose qw/Str/;
81393881 6
d4667bef 7extends 'Reaction::UI::ViewPort::Field::Mutable::Password';
81393881 8
7b5e71ad 9has check_value => (is => 'rw', isa => Str, );
10has check_label => (is => 'rw', isa => Str, lazy_build => 1);
d4667bef 11
81393881 12sub _build_check_label {
13 my $orig_label = shift->label;
14 return "Confirm ${orig_label}";
d4667bef 15}
24185a7d 16
81393881 17#maybe both check_value and value_string should have triggers ?
d4667bef 18#that way if one even happens before the other it would still work?
81393881 19around adopt_value_string => sub {
20 my $orig = shift;
21 my ($self) = @_;
22 return $orig->(@_) if $self->check_value eq $self->value_string;
23 $self->message("Passwords do not match");
24 return;
25};
26
27#order is important check_value should happen before value here ...
28#i don't like how this works, it's unnecessarily fragile, but how else ?
29around accept_events => sub { ('check_value', shift->(@_)) };
30
31around can_sync_to_action => sub {
32 my $orig = shift;
33 my ($self) = @_;
34 return $orig->(@_) if $self->check_value eq $self->value_string;
35 $self->message("Passwords do not match");
36 return;
37};
38
39__PACKAGE__->meta->make_immutable;
40
24185a7d 411;
d4667bef 42
43__END__;