2 * Copyright (C) 2021 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.vaadin
.data
.validator
;
11 import com
.vaadin
.data
.validator
.AbstractStringValidator
;
12 import com
.vaadin
.ui
.PasswordField
;
15 * Checks that the passwords entered in two password fields match.
16 * Intended to be added as validator to the second field of the
17 * {@link PasswordField} pair.
19 * @author a.kohlbecker
22 public class PasswordsMatchValidator
extends AbstractStringValidator
{
24 private static final long serialVersionUID
= -9048318480638222817L;
26 private PasswordField firstField
;
27 private PasswordField secondField
;
29 public PasswordsMatchValidator(String errorMessage
, PasswordField firstField
, PasswordField secondField
) {
31 this.firstField
= firstField
;
32 this.secondField
= secondField
;
33 firstField
.addValueChangeListener(event
-> {
39 protected boolean isValidValue(String value
) {
40 return firstField
.getValue().equals(secondField
.getValue());