CSenshi / Validator

Easy-to-use, Highly Configurable Python Data Validator. Inspired by Laravel Validator
https://pypi.org/project/validator/
MIT License
46 stars 23 forks source link

Change __call__ to check #28

Closed CSenshi closed 4 years ago

CSenshi commented 4 years ago

As for now we have Rules as callable classes. It doesn't seem user friendly, so lets change it to use check() method, see example below for between rule:

Now: Between(18, 30)(25) After: Between(18, 30).check(25)

l3str4nge commented 4 years ago

Hello! I am interested to contribute. @nikalosa, have you started working on this problem?

nikalosa commented 4 years ago

Hi @mateuszz0000 , feel free to work on this issue. We appreciate your interest in our project.

CSenshi commented 4 years ago

@mateuszz0000 If you are willing to contribute I'll assign this issue to you .

I'll try make it more specific

  1. We need to change all Rules (in the directory 'rules_src') so that naming __call__ is changed to check

  2. We need to change all of rule's doctests for example now we have something like this:

    >>> TrueBetween = Between(2, 15)
    >>> TrueBetween(23)
    False

    we need to change it to:

    >>> Between(2, 15).check(23)
    False
  3. We have parent class of all rules called Rule (located at validator/rules_src/__init__.py). we need to encapsulate new method check into __call___ So now we have:

    def __call__(self, arg):
        return False

    we need to have:

    def __call__(self, arg):
        return self.check(arg)

    Good luck and don't hesitate on questions! :100:

l3str4nge commented 4 years ago

Would be great! Thanks :)