summaryrefslogtreecommitdiffstats
path: root/documentation/components
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/components')
-rw-r--r--documentation/components/components-fields.asciidoc12
1 files changed, 5 insertions, 7 deletions
diff --git a/documentation/components/components-fields.asciidoc b/documentation/components/components-fields.asciidoc
index c963c96ebe..1415f98e73 100644
--- a/documentation/components/components-fields.asciidoc
+++ b/documentation/components/components-fields.asciidoc
@@ -156,20 +156,18 @@ whether or not the given input was valid.
----
class MyValidator implements Validator<String> {
@Override
- public Result<String> apply(String value, ValueContext context) {
- if(input.length() == 6) {
- return Result.ok(input);
+ public ValidationResult apply(String value, ValueContext context) {
+ if(value.length() == 6) {
+ return ValidationResult.ok();
} else {
- return Result.error(
+ return ValidationResult.error(
"Must be exactly six characters long");
}
}
}
----
-Because [methodname]#Result.ok# takes the valid value as an argument, a validator
-can also do some sanitization on valid inputs, such as removing leading and
-trailing whitespace from a string. Since [interfacename]#Validator# is a functional
+Since [interfacename]#Validator# is a functional
interface, you can often simply write a lambda expression instead of a full class
declaration. There is also an [methodname]#withValidator# overload that creates a
validator from a boolean function and an error message.