code: protected function serializeModelErrors($model)
      {
          $this->response->setStatusCode(422, 'Data Validation Failed.');
          $result = [];
          foreach ($model->getFirstErrors() as $name => $message) {
              $result[] = [
                  'field' => $name,
                  'message' => $message,
              ];
          }
  
          return $result;
      }
docs: Serializes the validation errors in a model.
  @param Model $model
  @return array the array representation of the errors