Feature #35354

Additional variants to annotate Validators

Added by Adrian Föder over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Could have
Category:
Validation
Target version:
-
Start date:
2012-03-29
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

Currently (afaik), the only option to set a validator to a model property is to annotate it in the vicinity of the appropriate method property:

    /**
     * @FLOW3\Validate(type="NotEmpty")
     * @FLOW3\Validate(type="RegularExpression", options={ "regularExpression"="/^[mf]$/" })
     * @var string
     * @ORM\Column(length=1)
     */
    protected $gender;

    /**
     * @FLOW3\Validate(type="NotEmpty")
     * @var \TYPO3\Party\Domain\Model\PersonName
     * @ORM\OneToOne
     */
    protected $name;

I now have two additional options in mind, one would be via Configuration.yaml (or maybe even an additional Validation.yaml:

-
  property: \Acme\Northwind\Person.gender
  validators:
    - NotEmpty
    - RegularExpression
        options:
          regularExpression: /^[mf]$/
-
  property: \TYPO3\Party\Domain\Model\PersonName.firstName
  validators:
    - NotEmpty
    - StringLength
        options:
          minimumLength: 2

-
  #dito for .lastName

Second would be to allow "deep" annotating via the parameter we already know from method argument annotation:

    /**
     * @FLOW3\Validate(type="NotEmpty")
     * @FLOW3\Validate("$firstName", type="NotEmpty")
     * @FLOW3\Validate("$lastName", type="NotEmpty")
     * @var \TYPO3\Party\Domain\Model\PersonName
     * @ORM\OneToOne
     */
    protected $name;

(for this example, remember \TYPO3\Party\Domain\Model\PersonName has properties firstName and lastName).


Related issues

Related to TYPO3.Flow - Feature #37373: Make annotation overrides / "injection" via Objects.yaml possibleUnder ReviewMarc Neuhaus2012-05-21

Actions
#1

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Karsten Dambekalns

The first one would come "for free" with #37373 and the second one seems to be confusing for me. You might look at PersonName and wonder why on earth validation fails for seemingly weird reasons.

#2

Updated by Adrian Föder over 9 years ago

  • Status changed from Needs Feedback to Closed

great, I'm perfectly fine with having the first option.

Also available in: Atom PDF