]> git.mxchange.org Git - jcoreee.git/blob - src/org/mxchange/jsfcore/validator/string/names/NameValidator.java
45b4cf7919c1acc96fe81da44561c93dd116f71a
[jcoreee.git] / src / org / mxchange / jsfcore / validator / string / names / NameValidator.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\r
4  * This program is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
16   */\r
17 package org.mxchange.jsfcore.validator.string.names;\r
18 \r
19 import java.text.MessageFormat;\r
20 import javax.faces.component.UIComponent;\r
21 import javax.faces.context.FacesContext;\r
22 import javax.faces.validator.Validator;\r
23 import javax.faces.validator.ValidatorException;\r
24 import org.mxchange.jsfcore.validator.string.BaseStringValidator;\r
25 \r
26 /**\r
27  * A validation class for names, such as first name or family name.\r
28  *\r
29  * @author Roland Haeder\r
30  */\r
31 public class NameValidator extends BaseStringValidator implements Validator {\r
32         @Override\r
33         public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {\r
34                 // Trace message\r
35                 this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value));\r
36 \r
37                 // All accepted, required fields\r
38                 String[] requiredFileds = {"firstName", "familyName"};\r
39 \r
40                 // Pre-validation (e.g. not null, not a string, empty string ...)\r
41                 super.preValidate(context, component, value, requiredFileds);\r
42 \r
43                 // Trace message\r
44                 this.getLogger().trace("EXIT!");\r
45         }\r
46 }\r