Feature #35354
Additional variants to annotate Validators
| Status: | Closed | Start date: | 2012-03-29 | |
|---|---|---|---|---|
| Priority: | Could have | Due date: | ||
| Assignee: | Karsten Dambekalns | % Done: | 0% |
|
| Category: | Validation | |||
| Target version: | - | |||
| PHP Version: | Complexity: | |||
| Has patch: | No | |||
| Votes: | 1 (View) |
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:
1 /**
2 * @FLOW3\Validate(type="NotEmpty")
3 * @FLOW3\Validate(type="RegularExpression", options={ "regularExpression"="/^[mf]$/" })
4 * @var string
5 * @ORM\Column(length=1)
6 */
7 protected $gender;
8
9 /**
10 * @FLOW3\Validate(type="NotEmpty")
11 * @var \TYPO3\Party\Domain\Model\PersonName
12 * @ORM\OneToOne
13 */
14 protected $name;
I now have two additional options in mind, one would be via Configuration.yaml (or maybe even an additional Validation.yaml:
1 -
2 property: \Acme\Northwind\Person.gender
3 validators:
4 - NotEmpty
5 - RegularExpression
6 options:
7 regularExpression: /^[mf]$/
8 -
9 property: \TYPO3\Party\Domain\Model\PersonName.firstName
10 validators:
11 - NotEmpty
12 - StringLength
13 options:
14 minimumLength: 2
15
16 -
17 #dito for .lastName
Second would be to allow "deep" annotating via the parameter we already know from method argument annotation:
1 /**
2 * @FLOW3\Validate(type="NotEmpty")
3 * @FLOW3\Validate("$firstName", type="NotEmpty")
4 * @FLOW3\Validate("$lastName", type="NotEmpty")
5 * @var \TYPO3\Party\Domain\Model\PersonName
6 * @ORM\OneToOne
7 */
8 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 ... | Under Review | 2012-05-21 |
History
Updated by Karsten Dambekalns 12 months 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.
Updated by Adrian Föder 11 months ago
- Status changed from Needs Feedback to Closed
great, I'm perfectly fine with having the first option.