Feature #31373
Annotation to enforce validation on setter
Status: | Rejected | Start date: | 2011-10-28 | |
---|---|---|---|---|
Priority: | Could have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Validation | |||
Target version: | TYPO3 Flow Base Distribution - 1.1 | |||
PHP Version: | Complexity: | |||
Has patch: | No |
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
History
#1 Updated by Jordy de Jong almost 4 years 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?
#2 Updated by Mr. Hudson almost 4 years 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
#3 Updated by Karsten Dambekalns almost 4 years ago
- Category set to Validation
- Target version set to 1.1
#4 Updated by Karsten Dambekalns almost 4 years 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...
#5 Updated by Christian Müller almost 4 years 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.
#6 Updated by Jordy de Jong almost 4 years 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?
#7 Updated by Karsten Dambekalns almost 4 years ago
#8 Updated by Jordy de Jong almost 4 years 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.
#9 Updated by Christian Müller over 3 years ago
- Status changed from Under Review to Rejected