Skip to content

Commit

Permalink
Docs: Update README (#25)
Browse files Browse the repository at this point in the history
# Goal 
* The aim of this PR is to update the README file with new parameters,
providing more clarity and precision in the validation process.

---------

Co-authored-by: Pierre Camilleri <[email protected]>
  • Loading branch information
Sarrabah and pierrecamilleri authored Nov 20, 2024
1 parent 09658c4 commit cb2f4d3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ The package is published on PyPI. Install with :
## Usage

```python
from frformat import Departement
from frformat import Departement, Options, Millesime

print(Departement.description())
Departement.is_valid("Haute-Vienne")

_options = Options(
ignore_case=True,
ignore_accents=True,
ignore_extra_whitespace=True
)
Departement(Millesime.LATEST, _options).is_valid("haute-vienne")
# True
Departement.is_valid("Canyon Cosmo")
Departement(Millesime.M2023, _options).is_valid("Canyon Cosmo")
# False
```
For more details, consult the [Options](./src/frformat/options.py) data class.

For better performance on big amounts of data, use in conjunction with numpy.

Expand Down
43 changes: 18 additions & 25 deletions src/frformat/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,27 @@
@dataclass
class Options:
"""
The class Options is used to represent a list of options to validate a French format.
Attributes:
ignore_case: Boolean
Indicates if case should be ignored.
When set to True, all characters in the string will be converted to lowercase.
ignore_accents: Boolean
Indicates if accents should be ignored.
When set to True, characters with accents will be replaced with their non-accented counterparts.
Example: 'à' will be replaced by 'a'.
replace_non_alphanumeric_with_space: Boolean
Indicates if non-alphanumeric characters should be ignored.
When set to True, punctuation marks and symbols will be replaced by a space.
ignore_extra_whitespace: Boolean
Indicates if extra white space should be ignored.
When set to True, multiple consecutive spaces will be treated as a single space, and leading or trailing spaces will be removed.
extra_valid_values: Frozenset of string
A collection of additional valid values.
This set includes any extra values that should be considered valid during the validation process, beyond the original set of valid values.
This allows for customized validation rules to accommodate special cases or exceptions.
The class Options is used to represent a list of options to validate a French format.
"""

ignore_case: bool = False
""" Indicates if case should be ignored.
When set to True, all characters in the string will be converted to lowercase."""

ignore_accents: bool = False
""" Indicates if accents should be ignored.
When set to True, characters with accents will be replaced with their non-accented counterparts.
Example: 'à' will be replaced by 'a'."""

replace_non_alphanumeric_with_space: bool = False
""" Indicates if non-alphanumeric characters should be ignored.
When set to True, punctuation marks and symbols will be replaced by a space."""

ignore_extra_whitespace: bool = False
extra_valid_values: FrozenSet = frozenset()
"""Indicates if extra white space should be ignored.
When set to True, multiple consecutive spaces will be treated as a single space, and leading or trailing spaces will be removed."""

extra_valid_values: FrozenSet[str] = frozenset()
"""A collection of additional valid values.
This set includes any extra values that should be considered valid during the validation process, beyond the original set of valid values.
This allows for customized validation rules to accommodate special cases or exceptions."""

0 comments on commit cb2f4d3

Please sign in to comment.