@@ -16,7 +16,7 @@ This library supports **`Kotlin`** aswell
16
16
17
17
## Sample
18
18
19
- Java
19
+ ### Java
20
20
21
21
``` java
22
22
import static br.com.fluentvalidator.predicate.ComparablePredicate.equalTo ;
@@ -32,26 +32,27 @@ import br.com.fluentvalidator.AbstractValidator;
32
32
33
33
public class JavaValidatorBoy extends AbstractValidator<Boy > {
34
34
35
- @Override
36
- protected void rules () {
35
+ @Override
36
+ protected void rules () {
37
37
38
- ruleFor(Boy :: getGender)
39
- .must(equalTo(Gender . MALE ))
40
- .when(not(nullValue()))
41
- .withMessage(" gender of boy must be MALE" )
42
- .withFieldName(" gender" )
43
- .critical();
38
+ ruleFor(Boy :: getGender)
39
+ .must(equalTo(Gender . MALE ))
40
+ .when(not(nullValue()))
41
+ .withMessage(" gender of boy must be MALE" )
42
+ .withFieldName(" gender" )
43
+ .critical();
44
44
45
- ruleFor(Boy :: getName)
46
- .must(stringContains(" John" ))
47
- .when(not(stringEmptyOrNull()))
48
- .withMessage(" child name must contains key John" )
49
- .withFieldName(" name" );
50
- }
45
+ ruleFor(Boy :: getName)
46
+ .must(stringContains(" John" ))
47
+ .when(not(stringEmptyOrNull()))
48
+ .withMessage(" child name must contains key John" )
49
+ .withFieldName(" name" );
50
+ }
51
51
52
52
}
53
53
```
54
- Kotlin
54
+
55
+ ### Kotlin
55
56
56
57
``` kotlin
57
58
import br.com.fluentvalidator.predicate.ComparablePredicate.equalTo;
@@ -67,24 +68,24 @@ import br.com.fluentvalidator.AbstractValidator;
67
68
68
69
class KotlinValidatorBoy : AbstractValidator <Boy > {
69
70
70
- constructor () : super ();
71
-
72
- override fun rules () {
73
-
74
- ruleFor(Boy ::getGender)
75
- .must(equalTo(Gender .MALE ))
76
- .`when `(not (nullValue()))
77
- .withMessage(" gender of boy must be MALE" )
78
- .withFieldName(" gender" )
79
- .critical();
80
-
81
- ruleFor(Boy ::getName)
82
- .must(stringContains(" John" ))
83
- .`when `(not (stringEmptyOrNull()))
84
- .withMessage(" child name must contains key John" )
85
- .withFieldName(" name" );
86
- }
87
-
71
+ constructor () : super ();
72
+
73
+ override fun rules () {
74
+
75
+ ruleFor(Boy ::getGender)
76
+ .must(equalTo(Gender .MALE ))
77
+ .`when `(not (nullValue()))
78
+ .withMessage(" gender of boy must be MALE" )
79
+ .withFieldName(" gender" )
80
+ .critical();
81
+
82
+ ruleFor(Boy ::getName)
83
+ .must(stringContains(" John" ))
84
+ .`when `(not (stringEmptyOrNull()))
85
+ .withMessage(" child name must contains key John" )
86
+ .withFieldName(" name" );
87
+ }
88
+
88
89
}
89
90
```
90
91
0 commit comments