1 package Reaction::UI::ViewPort::Field::Mutable::MatchingPasswords;
4 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::ViewPort::Field::Mutable::Password';
8 has check_value => (is => 'rw', isa => 'Str', );
9 has check_label => (is => 'rw', isa => 'Str', lazy_build => 1);
11 sub _build_check_label {
12 my $orig_label = shift->label;
13 return "Confirm ${orig_label}";
16 #maybe both check_value and value_string should have triggers ?
17 #that way if one even happens before the other it would still work?
18 around adopt_value_string => sub {
21 return $orig->(@_) if $self->check_value eq $self->value_string;
22 $self->message("Passwords do not match");
26 #order is important check_value should happen before value here ...
27 #i don't like how this works, it's unnecessarily fragile, but how else ?
28 around accept_events => sub { ('check_value', shift->(@_)) };
30 around can_sync_to_action => sub {
33 return $orig->(@_) if $self->check_value eq $self->value_string;
34 $self->message("Passwords do not match");
38 __PACKAGE__->meta->make_immutable;