From d9b09510771d39359f02544d51a3f43a5898736a Mon Sep 17 00:00:00 2001 From: Jens Nistler Date: Wed, 16 Oct 2024 16:43:01 +0200 Subject: [PATCH] feat: improve documentation on concatenation of different field types, closes #60 --- CHANGELOG.md | 5 +++++ README.md | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b01ef..7d05fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 7d129b7..c547e52 100644 --- a/README.md +++ b/README.md @@ -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