Feature #6993

Support declaration of additional validation rules by object accessor syntax

Added by Robert Lemke about 11 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
Validation
Start date:
2010-03-24
Due date:
% Done:

100%

Estimated time:
7.00 h
PHP Version:
Has patch:
Complexity:

Description

It is possible to declare additional validation rules in the doc comment of an action methods:

    /**
     * Creates a new participant + account.
     *
     * @param \F3\Conference\Domain\Model\Participant $newParticipant
     * @param string $password
     * @return void
     * @validate $password StringLength(minimum = 5)
     */
    public function createAction(\F3\Conference\Domain\Model\Participant $newParticipant, $password) {
    ...

However, it's not possible to declare a validation rule which refers to a sub object of one of the method arguments. In the above example it would be nice to declare that the first name of the person name of the new participant must not be empty (= is required). This could be achieved by supporting the object accessor syntax known from Fluid templates:

    /**
     * Creates a new participant + account.
     *
     * @param \F3\Conference\Domain\Model\Participant $newParticipant
     * @param string $password
     * @return void
     * @validate $newParticipant.name.firstName NotEmpty
     * @validate $password StringLength(minimum = 5)
     */
    public function createAction(\F3\Conference\Domain\Model\Participant $newParticipant, $password) {
    ...

In its first implementation, this new syntax will only apply to @validate annotations in action methods.

#1

Updated by Robert Lemke about 11 years ago

  • Status changed from New to Accepted
  • % Done changed from 0 to 10
  • Estimated time set to 4.00 h
#2

Updated by Robert Lemke about 11 years ago

  • Estimated time changed from 4.00 h to 7.00 h
#3

Updated by Robert Lemke about 11 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 10 to 100

Applied in changeset r4013.

Also available in: Atom PDF