Repository: codingedward/flask-sieve

Issue:
Max Rule Not Working for Numeric String
My rule is this

rules = {
                'card_number': ['bail', 'required', 'string', 'max:20'],
                'card_expiry_date': ['bail', 'required','string', 'max:8'],
                'card_cvv': ['bail', 'required', 'string', 'max:8']
            }

I am passing the values 

card_number = "876545666"
card_expiry_Date="0234"
card_cvv="123"


but this show error max value must be 20. 

How can we validate that the string characters max:20 for value "8777745434"

Comments:

Patch:
diff --git a/.gitignore b/.gitignore
index fb871be..88ecb85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 .*.swn
 .*.swo
 .*.swp
+.vim
 .coverage
 docs/build
 .DS_Store
diff --git a/flask_sieve/rules_processor.py b/flask_sieve/rules_processor.py
index 1ebae7a..7b7f004 100644
--- a/flask_sieve/rules_processor.py
+++ b/flask_sieve/rules_processor.py
@@ -152,9 +152,9 @@ class RulesProcessor:
         self._assert_params_size(size=1, params=params, rule='before_or_equal')
         return self._compare_dates(value, params[0], operator.le)
 
-    def validate_between(self, value, params, **kwargs):
+    def validate_between(self, value, params, rules, **kwargs):
         self._assert_params_size(size=2, params=params, rule='between')
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         lower = self._get_size(params[0])
         upper = self._get_size(params[1])
         return lower <= value and value <= upper
@@ -251,15 +251,15 @@ class RulesProcessor:
             return self.validate_required(value, attribute, nullable)
         return True
 
-    def validate_gt(self, value, params, **kwargs):
+    def validate_gt(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='gt')
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         upper = self._get_size(self._attribute_value(params[0]))
         return value > upper
 
-    def validate_gte(self, value, params, **kwargs):
+    def validate_gte(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='gte')
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         upper = self._get_size(self._attribute_value(params[0]))
         return value >= upper
 
@@ -362,27 +362,27 @@ class RulesProcessor:
     def validate_json(self, value, **kwargs):
         return self._can_call_with_method(json.loads, value)
 
-    def validate_lt(self, value, params, **kwargs):
+    def validate_lt(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='lt')
         if self._is_value_empty(value):
             return False
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         lower = self._get_size(self._attribute_value(params[0]))
         return value < lower
 
-    def validate_lte(self, value, params, **kwargs):
+    def validate_lte(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='lte')
         if self._is_value_empty(value):
             return False
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         lower = self._get_size(self._attribute_value(params[0]))
         return value <= lower
 
-    def validate_max(self, value, params, **kwargs):
+    def validate_max(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='max')
         if self._is_value_empty(value):
             return False
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         upper = self._get_size(params[0])
         return value <= upper
 
@@ -396,9 +396,9 @@ class RulesProcessor:
             return value.mimetype in params
         return kind.mime in params
 
-    def validate_min(self, value, params, **kwargs):
+    def validate_min(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='min')
-        value = self._get_size(value)
+        value = self._get_size(value, rules)
         lower = self._get_size(params[0])
         return value >= lower
 
@@ -487,7 +487,7 @@ class RulesProcessor:
         other_value = self._attribute_value(params[0])
         return value == other_value
 
-    def validate_size(self, value, params, **kwargs):
+    def validate_size(self, value, params, rules, **kwargs):
         self._assert_params_size(size=1, params=params, rule='size')
         self._assert_with_method(float, params[0])
         other_value = params[0]
@@ -495,7 +495,7 @@ class RulesProcessor:
             other_value = float(other_value)
         else:
             other_value = int(other_value)
-        return self._get_size(value) == other_value
+        return self._get_size(value, rules) == other_value
 
     def validate_starts_with(self, value, params, **kwargs):
         self._assert_params_size(size=1, params=params, rule='starts_with')
diff --git a/setup.py b/setup.py
index a360d6e..eec224a 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ setup(
     name='flask-sieve',
     description='A Laravel inspired requests validator for Flask',
     long_description='Find the documentation at https://flask-sieve.readthedocs.io/en/latest/',
-    version='2.0.0',
+    version='2.0.1',
     url='https://github.com/codingedward/flask-sieve',
     license='BSD-2',
     author='Edward Njoroge',


Test patch:
diff --git a/tests/test_rules_processor.py b/tests/test_rules_processor.py
index 3f32a1b..999b31b 100644
--- a/tests/test_rules_processor.py
+++ b/tests/test_rules_processor.py
@@ -597,6 +597,11 @@ class TestRulesProcessor(unittest.TestCase):
             rules={'field': ['max:10']},
             request={'field': self.image_file}
         )
+        self.assert_passes(
+            rules={'field': ['bail', 'required', 'string', 'max:10'],
+                   'card_cvv': ['bail', 'required', 'string', 'max:8']},
+            request={'field': '8777745434', 'card_cvv': '123'}
+        )
 
     def test_validates_mime_types(self):
         self.assert_passes(