You are here

protected function RestfulEntityBase::validateFields in RESTful 7

Validates an entity's fields before they are saved.

Parameters

\EntityDrupalWrapper $wrapper: A metadata wrapper for the entity.

Throws

\RestfulUnprocessableEntityException

1 call to RestfulEntityBase::validateFields()
RestfulEntityBase::entityValidate in plugins/restful/RestfulEntityBase.php
Validate an entity before it is saved.

File

plugins/restful/RestfulEntityBase.php, line 1514
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function validateFields($wrapper) {
  try {
    field_attach_validate($wrapper
      ->type(), $wrapper
      ->value());
  } catch (\FieldValidationException $e) {
    throw new RestfulUnprocessableEntityException($e
      ->getMessage());
  }
}