/** * @param array $data * @return bool */ public function isNewCommentValid(array $data) { $constraint = new Assert\Collection(['topic' => [new Assert\Type(['type' => 'int']), new Assert\NotBlank()], 'content' => [new Assert\NotBlank()]]); $this->lastErrors = $this->validator->validateValue($data, $constraint); return 0 === count($this->lastErrors); }
/** * Checks new topic data is valid * * Also updates $lastErrors property with any errors (or none) * * @param array $data * * @return bool */ public function isNewTopicValid(array $data) { $constraint = new Assert\Collection(['title' => [new Assert\Length(['max' => 120]), new Assert\NotBlank()], 'excerpt' => [new Assert\Length(['max' => 255]), new Assert\NotBlank()], 'details' => [new Assert\NotBlank()], 'owned_by_creator' => [new Assert\Type(['type' => 'bool']), new Assert\NotBlank()]]); $this->lastErrors = $this->validator->validateValue($data, $constraint); return 0 === count($this->lastErrors); }