Feature #31373
Annotation to enforce validation on setter
| Status: | Rejected | Start date: | 2011-10-28 | |
|---|---|---|---|---|
| Priority: | Could have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Validation | |||
| Target version: | TYPO3 Flow Base Distribution - 1.1 | |||
| PHP Version: | Complexity: | |||
| Has patch: | No | |||
| Votes: | 0 |
Description
Something like @FLOW3\ValidateOnSet which you can annotate to a setter in a model. On each call the generated proxy should check the validation rules for this property before setting and if validation fails throw some error.
Related issues
| related to TYPO3.Flow - Bug #31500: Argument validation for CLI requests is not done | Under Review | 2011-11-02 | ||
| related to TYPO3.Flow - Bug #31502: Validation during persistence got lost in Doctrine addition | Resolved | 2011-11-02 |
History
Updated by Jordy de Jong over 1 year ago
I've commited a fix to review.typo3.org
With this fix you can add the @FLOW3\ValidateOnSet annotation to your property, the proxy class builder makes sure a setter is created which enforces the validations for the property
Downside of this solution is that you have to add this validation to all your properties in all your models, maybe a generic setting is a better solution to enable this throughout your application?
Updated by Mr. Hudson over 1 year ago
- Status changed from New to Under Review
Patch set 3 of change I21c63047b3adaf3e0f72130b7f1748cbe1103e40 has been pushed to the review server.
It is available at http://review.typo3.org/6411
Updated by Karsten Dambekalns over 1 year ago
- Category set to Validation
- Target version set to 1.1
Updated by Karsten Dambekalns over 1 year ago
Two different concepts here. Christian wants to add validation to (existing) setters, Jordy created a change to annotate properties. But: why a new annotation? Why not simply add the existing Validate annotations to the setter methods?
It seems we need a clear concept first...
Updated by Christian Mueller over 1 year ago
Karsten Dambekalns wrote:
Two different concepts here. Christian wants to add validation to (existing) setters, Jordy created a change to annotate properties. But: why a new annotation? Why not simply add the existing Validate annotations to the setter methods?
It seems we need a clear concept first...
Yes, lets discuss this further. Actually the additional property was my idea, but I intended it on the set method. Your idea seems nice too but then you have duplicate code (annotations) in a way.
Updated by Jordy de Jong over 1 year ago
I thought adding the annotation to the property would be the more logical place, so it would be next to the defined validations you want to enforce in the corresponding setter
I agree that my proposed fix isn't the ideal solution.
Personally, I'm wondering why in FLOW3 the validations aren't always enforced, by default. Either in the setter methods or before persistance. Why would you want to persist an object that doesn't match the defined validations?
Updated by Karsten Dambekalns over 1 year ago
Updated by Jordy de Jong over 1 year ago
Do I understand correctly (from #31502) that validation during persistence is the intended way?
If so, I agree, because that would also have been my way of solving this.
Updated by Christian Mueller about 1 year ago
- Status changed from Under Review to Rejected