Feature #3093

Implement annotation based validation rules for models

Added by Robert Lemke over 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2009-04-15
Priority:Must have Due date:
Assigned To:Robert Lemke % Done:

100%

Category:Validation
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 1
PHP Version: Complexity:
Has patch:

Description

Make these @validate annotations work in a model:

    /**
     * The blog's name. Also acts as the identifier.
     *
     * @var string
     * @validate Alphanumeric, StringLength(minimum = 3, maximum = 50)
     * @identity
     */
    protected $name = '';

    /**
     * A short description of the blog
     *
     * @var string
     * @validate Text, StringLength(maximum = 150)
     */
    protected $description = '';

Associated revisions

Revision 838e2980
Added by Robert Lemke over 6 years ago

This commit is all about validation. Although the new features basically work, a few smaller features and tweak are missing before the whole concept works as intended. Documentation will follow (hopefully soon).

  • FLOW3: (Validation) Implemented annotation based validation for models. That means you now can define validation rules by adding @validate annotations to class properties and these rules will be enforced when arguments of this type are passed as controller arguments. Resolves #3093 but some fine tuning and small additional features are missing.
  • FLOW3: (Validation) Note that #3130 is not solved yet in this commit.
  • FLOW3: (MVC) Implemented a MVC Controller Arguments Validator which is able to validate a whole Arguments object. This is used during the mapAndValidate process in the controller. Addresses #3093.
  • FLOW3: (Property) The property mapper now accepts arrays as source and / or target.
  • FLOW3: (Property) mapAndValidate() will now truly validate the result of the mapping. If the result does not validate, the target remains unchanged.
  • FLOW3: (Validation) Removed the Filter Chain for now - it will surely come back but didn't work like it was currently implemented.
  • FLOW3: (Validation) Improved the AbstractValidator and added a new AbstractObjectValidator
  • FLOW3: (Validation) Adapted all validators to the new Validator interface and AbstractValidator
  • FLOW3: (Validation) Implemented a new Generic Object validator which can validate properties of any object
  • FLOW3: (Validation) Simplified the chaining of validators and during that process removed the ObjectValidatorChainValidator
  • FLOW3: Added and adapted many tests

History

#1 Updated by Robert Lemke over 6 years ago

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

Applied in changeset r2185.

Also available in: Atom PDF