Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions core/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,43 @@ class Greeting
}
```

## Using the Group Sequence Provider

If you need to use a Group Sequence Provider, you'll have to tell the Serializer to ignore the getter added by the Interface:

```php
class Greeting implements GroupSequenceProvider
{
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
private ?int $id = null;

#[ORM\Column]
#[Assert\NotBlank(groups: ['needs_name'])
public string $name = '';

public function getId(): int
{
return $this->id;
}

// You need to add this Ignore statement.
#[Ignore]
public function getGroupSequence(): array|GroupSequence
{
$groups = [
'Greeting',
];

if ($this->getId() % 2) {
$groups[] = 'needs_name';
}

return new GroupSequence($groups);
}
}
```


## Validating Delete Operations

By default, validation rules that are specified on the API resource are not evaluated during DELETE operations. You need to trigger the validation in your code, if needed.
Expand Down