Skip to content

Commit

Permalink
feat: improve documentation on concatenation of different field types,
Browse files Browse the repository at this point in the history
…closes #60
  • Loading branch information
lociii committed Oct 16, 2024
1 parent e1c2cd1 commit d9b0951
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
-->

## [Unreleased]

### Changed
- Improved documentation on concatenation of different field types.

## [3.0.0] - 2024-09-10
### Breaking
- Removed `SCRUBBER_VALIDATION_WHITELIST` in favour of `SCRUBBER_REQUIRED_FIELD_MODEL_WHITELIST` - Thanks @GitRon
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ class Scrubbers:
Wrapper around `django.db.functions.Concat` to enable simple concatenation of scrubbers. This is useful if you want to
ensure a fields uniqueness through composition of, for instance, the `Hash` and `Faker` (see below) scrubbers.

When using different input field types, make sure to explicitly state an `output_field` type.

The following will generate random email addresses by hashing the user-part and using `faker` for the domain part:

```python
class Scrubbers:
email = scrubbers.Concat(scrubbers.Hash('email'), models.Value('@'), scrubbers.Faker('domain_name'))
email = scrubbers.Concat(scrubbers.Hash('email'), models.Value('@'), scrubbers.Faker('domain_name'), output_field=models.EmailField())
```

### Faker
Expand Down

0 comments on commit d9b0951

Please sign in to comment.