silverbackhq / pyvalitron

🔰 Python Inputs Validation Library.
MIT License
1 stars 1 forks source link

Docs #1

Closed tommyp6 closed 5 years ago

tommyp6 commented 5 years ago

@Clivern I saw the docs on th GitHub Pages and there is some example code I think its wrong :

from pyvalitron.form import Form

form = Form({
    'test_field1': {
        'value': 'Hello World',
        'validate': {
            'length_between': {
                'param': [1, 12],
                'error': 'Input lenght must be between 1 and 12 characters'
            }
        }
    },
    'test_field2': {
        'value': 'Hello World',
        'validate': {
            'length_between': {
                'param': [1, 9],
                'error': 'Input lenght must be between 1 and 12 characters'
            }
        }
    }
})
form.process()
errors = form.get_errors()
print(errors['test_field2'])   # Input lenght must be between 1 and 12 characters

I don't know how the code works but won't it be something like that :

from pyvalitron.form import Form

form = Form({
    'test_field1': {
        'value': 'Hello World',
        'validate': {
            'length_between': {
                'param': [1, 12],
                'error': 'Input lenght must be between 1 and 12 characters'
            }
        }
    },
    'test_field2': {
        'value': 'Hello World',
        'validate': {
            'length_between': {
                'param': [1, 9], # I guess that means that it must be from 1 to 9
                'error': 'Input lenght must be between 1 and 9 characters'
            }
        }
    }
})
form.process()
errors = form.get_errors()
print(errors['test_field2'])   # Input lenght must be between 1 and 9 characters
Clivern commented 5 years ago

Yeah, copy and paste issue, 97373797a & eefddf7bfa6b8 fix that Thanks @TommyPujol06