python-validators / validators

Python Data Validation for Humans™.
MIT License
977 stars 155 forks source link

validators.length need min_val and max_val #323

Closed prrvchr closed 7 months ago

prrvchr commented 9 months ago

After an upgrade from 0.20.0 to 0.22.0 I have some code that no longer works:

def isStringValid(value):
    if validators.length(value, min_val=1):
        return True
    return False

To get around the problem I need to modify the code:

def isStringValid(self, value):
    max_val = max(1, len(value))
    if validators.length(value, min_val=1, max_val=max_val):
        return True
    return False
prrvchr commented 7 months ago

Ok, thanks for the fix.