| 123456789101112131415161718192021222324252627282930313233343536 |
- #pragma once
- #include <string>
- #include <jvalidate/constraint/constraint.h>
- #include <jvalidate/forward.h>
- namespace jvalidate::constraint {
- class MinLengthConstraint : public SimpleConstraint<MinLengthConstraint> {
- private:
- int64_t value_;
- public:
- MinLengthConstraint(int64_t value) : value_(value) {}
- bool operator()(std::string_view arg) const { return arg.size() >= value_; }
- };
- class MaxLengthConstraint : public SimpleConstraint<MaxLengthConstraint> {
- private:
- int64_t value_;
- public:
- MaxLengthConstraint(int64_t value) : value_(value) {}
- bool operator()(std::string_view arg) const { return arg.size() <= value_; }
- };
- class PatternConstraint : public SimpleConstraint<PatternConstraint> {
- public:
- std::string regex;
- public:
- PatternConstraint(std::string const & regex) : regex(regex) {}
- };
- }
|