arpadboda commented on a change in pull request #618: POC: MINIFICPP-985 - 
Implement listvalidators
URL: https://github.com/apache/nifi-minifi-cpp/pull/618#discussion_r307690730
 
 

 ##########
 File path: libminifi/include/core/PropertyValidation.h
 ##########
 @@ -308,6 +288,66 @@ class TimePeriodValidator : public PropertyValidator {
   }
 };
 
+class RegexValidator : public PropertyValidator {
+ public:
+  explicit RegexValidator(const std::string& pattern)
+  : PropertyValidator("REGULAR_EXPRESSION_VALIDATOR"){
+    regex_ = utils::Regex(pattern);
+  }
+  ValidationResult validate(const std::string &subject, const 
std::shared_ptr<minifi::state::response::Value> &input) const {
+    return validate(subject, input->getStringValue());
+  }
+
+  ValidationResult validate(const std::string &subject, const std::string 
&input) const {
+    bool result = regex_.match(input);
+    return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input).isValid(result).build();
+  }
+ private:
+  mutable utils::Regex regex_;
+};
+
+template <typename T, typename 
std::enable_if<std::is_base_of<PropertyValidator, T>::value>::type* = nullptr>
+class ListValidator : public PropertyValidator{
+ public:
+  explicit ListValidator(T val)
+  : PropertyValidator("LIST_VALIDATOR"),
 
 Review comment:
   The name should somehow contain the underlying validator's name to work 
properly with C2. 
   This should be adjusted to the way Java MiNiFi or NiFi works. 
   
   That's why I made getName() virtual. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to