Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions docs/en/appendices/6-0-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ deprecation warnings.
- `Cake\Event\Event::getSubject()` can now return `null` if the event has no
subject instead of throwing an exception.

- `Model.buildValidator` is now dispatched before the named validation method,
allowing listeners to register providers used by `Validator::add()`. Listeners
that inspect rules added by `validationDefault()` must account for this order.

## Breaking Changes

### Renamed Methods
Expand Down
6 changes: 4 additions & 2 deletions docs/en/orm/table-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ been replaced with the [Map Reduce](../orm/retrieving-data-and-resultsets#map-re

`method` Cake\\ORM\\Table::**buildValidator**(EventInterface $event, Validator $validator, $name): void

The `Model.buildValidator` event is fired when `$name` validator is created.
Behaviors, can use this hook to add in validation methods.
The `Model.buildValidator` event is fired when the `$name` validator is created,
before the table's `validationDefault()` or other named validation method runs.
Behaviors and other listeners can register providers here so that their rules
are available when the validation method calls `Validator::add()`.

### buildRules

Expand Down
5 changes: 3 additions & 2 deletions docs/en/orm/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ When building an entity with validation enabled the following occurs:

1. The validator object is created.
2. The `table` and `default` validation provider are attached.
3. The named validation method is invoked. For example `validationDefault`.
4. The `Model.buildValidator` event will be triggered.
3. The `Model.buildValidator` event is triggered, allowing behaviors and other
listeners to register validation providers.
4. The named validation method is invoked. For example `validationDefault`.
5. Request data will be validated.
6. Request data will be type-cast into types that match the column types.
7. Errors will be set into the entity.
Expand Down
Loading