Extbase validation controlled/ overruled via TypoScript for TYPO3 extensions
The PxValidation extension enables the possibility to define different validation configuration in your TypoScript for each Extbase-Controller-Action without touching the affected extension itself. This makes it easy to change the default validation behaviour of vendor extensions without changing their code. But the greatest benefit is that it opens the option to declare multiple variants of validation rules within one page tree. It is even possible to nest validation rules, so you can validate child objects.
The recommended way to install the extension is using Composer.
Run the following command within your Composer based TYPO3 project:
composer require portrino/px_validation
Download and install the extension with the extension manager module.
- Include the static TypoScript of the extension.
- Create some TypoScript in your e.g. "site_package" extension to override the validation rules of any other extension
- See example below:
namespace VendorName\ExtensionName\Controller;
class FooController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* action create
*
* @param \VendorName\ExtensionName\Domain\Model\FooBar $fooBar
* @return void
*/
public function createAction(\VendorName\ExtensionName\Domain\Model\FooBar $fooBar) {
...
}
}
plugin.tx_pxvalidation.settings {
VendorName\ExtensionName\Controller\FooController {
actionMethodName {
fooBar {
# (default 0) if 1, then the validation rules defined in the property, model or controller are NOT executed
overwriteDefaultValidation = 1
objectValidators {
0 = @TYPO3\CMS\Extbase\Annotation\Validate("VendorName\ExtensionName\Domain\Validator\FooValidator", options={"firstOption": value1, "secondOption": 123456})
1 = @TYPO3\CMS\Extbase\Annotation\Validate("VendorName\ExtensionName\Domain\Validator\BarValidator", options={"firstOption": value1})
}
propertyValidators {
foo {
0 = @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
}
bar {
0 = @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
1 = @TYPO3\CMS\Extbase\Annotation\Validate("StringLength", options={"minimum": 3, "maximum": 50})
2 = @TYPO3\CMS\Extbase\Annotation\Validate("VendorName\ExtensionName\Domain\Validator\CustomValidator", options={"firstOption": value1})
}
childObject {
propertyValidators {
subProperty1 {
0 = @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
}
subProperty2 {
0 = @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
}
#...
}
}
}
}
}
}
}
Please look into the CHANGELOG file in the extension.
PxValidation uses semantic versioning, which means, that
- bugfix updates (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or security relevant stuff without breaking changes,
- minor updates (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes,
- and major updates (e.g. 1.0.0 => 2.0.0) breaking changes wich can be refactorings, features or bugfixes.
PxValidation | TYPO3 | PHP | Support / Development |
---|---|---|---|
4.0.x | 12.4 | 8.1 - 8.3 | features, bugfixes, security updates |
3.0.x | 11.5 | 7.4 - 8.2 | bugfixes, security updates |
2.0.x | 9.5 - 10.4 | 7.2 - 7.4 | none |
1.2.x | 9.5 | 7.2 - 7.4 | none |
1.1.x | 6.2 - 8.7 | 5.5 - 7.4 | none |
Pull Requests are gladly welcome! Nevertheless, please don't forget to add an issue and connect it to your pull requests. This is very helpful to understand what kind of issue the PR is going to solve.
Bugfixes: Please describe what kind of bug your fix solve and give us feedback how to reproduce the issue. We're going to accept only bugfixes if we can reproduce the issue.
- See the list of contributors who participated in this project.