Bug #9862

Base validators are built incorrectly

Added by Karsten Dambekalns about 11 years ago. Updated about 11 years ago.

Status:
Resolved
Priority:
Must have
Category:
Validation
Start date:
2010-09-21
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

When a base validator is built, any property that
  • has a @validate annotations
  • or holds a class for which a base validator exists
    gets a validator attached. Then any custom validator for a class is added.

Currently this is not working as expected. Consider this example:

class Node {

    /**
     * Workspace this node is contained in
     *
     * @var \F3\TYPO3CR\Domain\Model\Workspace
     */
    protected $workspace;

    /**
     * Identifier of this node which is unique within its workspace
     *
     * @var string
     * @validate uuid
     */
    protected $identifier;

This will check the $identifier to be an UUID and it will also check validity on $workspace (if the validator for that is not NULL). But if the uuid validation annotation is removed the $workspace property will no longer be validated as well.

#1

Updated by Karsten Dambekalns about 11 years ago

  • Status changed from Needs Feedback to Accepted
#2

Updated by Karsten Dambekalns about 11 years ago

  • Status changed from Accepted to Under Review
#3

Updated by Karsten Dambekalns about 11 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#4

Updated by Sebastian Kurfuerst about 11 years ago

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

Hey Karsten,

we have just found a severe regression with this patch:

In the BlogExample, the "Blog" object holds a reference to the "PostRepository" -- and now, a validator is built for the PostRepository, even though it is a SINGLETON object.

This should never happen for singletons IMHO, they should not be mappable at all by the propery mapper, but only injected via DI.

Greets,
Bastian, Andi and Sebastian :-)

#5

Updated by Karsten Dambekalns about 11 years ago

This should never happen for singletons IMHO, they should not be mappable at all by the propery mapper, but only injected via DI.

Well, is it singletons or should validators only be built for entities and value objects?

#6

Updated by Sebastian Kurfuerst about 11 years ago

I'd say only for entities / value objects.

#7

Updated by Karsten Dambekalns about 11 years ago

  • Status changed from Accepted to Under Review
#8

Updated by Karsten Dambekalns about 11 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 50 to 100

Also available in: Atom PDF