validators.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. =================
  2. Misago Validators
  3. =================
  4. Misago apps implement plenty of validators, some of which are considered public API. Those validators are per convention contained within ``validators`` module of their respective apps.
  5. misago.core.validators
  6. ======================
  7. validate_sluggable
  8. ------------------
  9. :py:class:`misago.core.validators.validate_sluggable`
  10. Callable class that validates if string can be converted to non-empty slug thats no longer than 255 characters.
  11. To you use it, first instantiate it. If you want to define custom error messages, you can pass them using ``error_short`` and ``error_long`` arguments on initializer. After that you can simply call the class like other validator functions to see if it raises ``ValidationError``::
  12. from misago.core.validators import validate_sluggable
  13. validator = validate_sluggable()
  14. validator(some_value)
  15. misago.users.validators
  16. =======================
  17. validate_username
  18. -----------------
  19. :py:class:`misago.users.validators.validate_username`
  20. Function that takes username and runs content, length, availability and ban check validation in this order via calling dedicated validators.