Skip to content

Commit

Permalink
Merge pull request #27 from todofixthis/develop
Browse files Browse the repository at this point in the history
Filters v3.2.1
  • Loading branch information
todofixthis authored Feb 6, 2023
2 parents 64e312c + a141f35 commit 91b1ade
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions docs/simple_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,36 @@ initialiser.
import filters as f
filter_ = f.Choice(choices=('Moe', 'Larry', 'Curly'))
runner = f.FilterRunner(f.Choice(choices=('Moe', 'Larry', 'Curly')))
runner = f.FilterRunner(filter_, 'Curly')
runner.apply('Curly')
assert runner.is_valid() is True
assert runner.cleaned_data == 'Curly'
runner = f.FilterRunner(filter_, 'Shemp')
runner.apply('Shemp')
assert runner.is_valid() is False
.. note::
The comparison is case-sensitive by default; you can override this by passing
``case_sensitive=False`` to the filter initialiser.

The ``choices`` passed to the filter initialiser are the 'canonical' ones; when
a match is found, the filter will always return the matching choice, rather than
the raw input.

.. code-block:: python
import filters as f
The comparison is case-sensitive; chain this filter with :ref:`case-fold` for
case-insensitive comparison (but note that this will modify the resulting
value).
runner = f.FilterRunner(
f.Choice(
choices=['Weiße Taube', 'Wellensittich', 'Spatz'],
case_sensitive=False
)
)
runner.apply('weisse taube')
assert runner.is_valid() is True
assert runner.cleaned_data == 'Weiße Taube'
.. _date:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[project]
name = "phx-filters"
version = "3.2.0"
version = "3.2.1"
description = "Validation and data pipelines made easy!"
readme = "README.rst"
requires-python = ">= 3.6"
Expand Down

0 comments on commit 91b1ade

Please sign in to comment.