09b35bee5a94d5223725fa169bae411e81121894
[JavaForFun] /
1 package de.example.symfony.validator.service.impl;
2
3 import java.util.Map;
4
5 import de.example.symfony.validator.ValidatorNumber;
6 import de.example.symfony.validator.ValidatorString;
7 import de.example.symfony.validator.service.ValidatorService;
8
9
10 public class ValidatorServiceImpl extends ValidatorService {
11         private static final String FROMID = "fromId";
12         private static final String TOID = "toId";
13         private static final String DESCRIPTION = "description";
14         
15         private String fromId;
16         private String toId;
17         private String description;
18
19         public ValidatorServiceImpl(Map<String, String> params) {
20             super(params);
21     }
22
23         @Override
24     protected void configureValidators() {      
25                 validators.put(FROMID, new ValidatorNumber.Builder().setRequired(true).setMin(5).build());
26                 validators.put(TOID, new ValidatorNumber.Builder().setRequired(true).setMax(100).build());
27                 validators.put(DESCRIPTION, new ValidatorString.Builder().setRequired(false).setMaxLength(70).setMinLength(5).build()); 
28     }
29
30         @Override
31     protected void configurePostValidators() {
32                 
33                 postValidators.put(FROMID, value ->
34                 {
35                         fromId = value;
36                 System.out.println("fromId: " + fromId); 
37                 });
38                 
39                 postValidators.put(TOID, value ->
40                 {
41                         toId = value;
42                 System.out.println("toId: " + toId);
43
44                 });
45                 
46                 postValidators.put(DESCRIPTION, value ->
47                 {
48                         description = value;
49                 System.out.println("description: " + description);
50
51                 });  
52     }
53
54 }