Skip to content

Commit

Permalink
Extend readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kolb committed Jun 8, 2024
1 parent 1fd277f commit 06ae38c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,19 @@ if ($userId->isEqualTo($command->userId)) {
}
```

Guard against invalid usages:
```php
$requestingUser->userId->mustNotBeEqualTo($command->targetUserId);
```

Or with a custom exception:
```php
$requestingUser->userId->mustNotBeEqualTo(
$command->targetUserId,
static fn () => new Exception\UserCanNotTargetItself(),
);
```

### Symfony serializer

If you're injecting the `SerializerInterface` directly, there is nothing to do. The normalizer for the id is automatically registered.
Expand Down

0 comments on commit 06ae38c

Please sign in to comment.