Lehel44 commented on a change in pull request #5028:
URL: https://github.com/apache/nifi/pull/5028#discussion_r622232273
##########
File path:
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
##########
@@ -151,7 +152,24 @@ public ValidationResult validate(final String subject,
final String value, final
}
};
- public static final Validator PORT_VALIDATOR = createLongValidator(1,
65535, true);
+ public static final Validator NETWORK_ADDRESS_VALIDATOR = new Validator() {
+ private final Pattern ipv4Pattern =
Pattern.compile("^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.(?!$)|$)){4}$");
+
+ @Override
+ public ValidationResult validate(final String subject, final String
value, final ValidationContext context) {
+
+ final String reason = "not a valid IP address";
+ final boolean isValidInetAddress = "localhost".equals(value) ||
isValid(value);
+ return new
ValidationResult.Builder().subject(subject).input(value).explanation(reason).valid(isValidInetAddress).build();
+ }
+
+ private boolean isValid(final String email) {
+ Matcher matcher = ipv4Pattern.matcher(email);
+ return matcher.matches();
+ }
+ };
+
+ public static final Validator PORT_VALIDATOR = createLongValidator(0,
65535, true);
Review comment:
It seems like every property needs a specific port. For now we don't
need the extended validator. I'll change this back to original.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]