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
3 changes: 3 additions & 0 deletions en/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,9 @@ come up when running a CLI script that directly sets properties on entities::
// Add validation rules
$rules->add(function($entity) {
$data = $entity->extract($this->getSchema()->columns(), true);
if (!$entity->isNew() && !empty($data)) {
$data += $entity->extract((array)$this->getPrimaryKey());
}
$validator = $this->getValidator('default');
$errors = $validator->validate($data, $entity->isNew());
$entity->setErrors($errors);
Expand Down
3 changes: 3 additions & 0 deletions fr/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,9 @@ qui définit des propriétés directement dans des entities::
// Ajoute des règles de validation
$rules->add(function($entity) {
$data = $entity->extract($this->getSchema()->columns(), true);
if (!$entity->isNew() && !empty($data)) {
$data += $entity->extract((array)$this->getPrimaryKey());
}
$validator = $this->getValidator('default');
$errors = $validator->validate($data, $entity->isNew());
$entity->setErrors($errors);
Expand Down
3 changes: 3 additions & 0 deletions ja/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ CLI スクリプトを走らせる時に起こり得るでしょう。 ::
// アプリケーションルールの追加
$rules->add(function($entity) {
$data = $entity->extract($this->getSchema()->columns(), true);
if (!$entity->isNew() && !empty($data)) {
$data += $entity->extract((array)$this->getPrimaryKey());
}
$validator = $this->getValidator('default');
$errors = $validator->validate($data, $entity->isNew());
$entity->setErrors($errors);
Expand Down