Feature #6993

Support declaration of additional validation rules by object accessor syntax

Added by Robert Lemke over 5 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2010-03-24
Priority:Should have Due date:
Assigned To:Robert Lemke % Done:

100%

Category:Validation
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 8 Estimated time:7.00 hours
PHP Version: Complexity:
Has patch:

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.

Associated revisions

Revision 801396ee
Added by Robert Lemke over 5 years ago

[+FEATURE] FLOW3 (Validation): The @validate annotations in action methods now support an object accessor syntax ($argument.subobject.subsubobject) for declaring additional validation rules referring to a property of a nested object. Resolves #6993
[~TASK] FLOW3 (Validation): Brushed up and unified the messages of most validators.
[~TASK] FLOW3 (Error): The var_dump method now also filters PHPUnit Invocation Mokers.

Revision 2d005788
Added by Robert Lemke over 5 years ago

[+FEATURE] FLOW3 (Validation): The @validate annotations in action methods now support an object accessor syntax ($argument.subobject.subsubobject) for declaring additional validation rules referring to a property of a nested object. Resolves #6993
[~TASK] FLOW3 (Validation): Brushed up and unified the messages of most validators.
[~TASK] FLOW3 (Error): The var_dump method now also filters PHPUnit Invocation Mokers.

History

#1 Updated by Robert Lemke over 5 years ago

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

#2 Updated by Robert Lemke over 5 years ago

  • Estimated time changed from 4.00 to 7.00

#3 Updated by Robert Lemke over 5 years ago

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

Applied in changeset r4013.

Also available in: Atom PDF