Compare commits
6 commits
master
...
feature/pr
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3c53a4de5b | ||
![]() |
26c8f8b83a | ||
![]() |
821891e559 | ||
![]() |
abc269f99a | ||
![]() |
a53f0213da | ||
![]() |
ed6ff64d34 |
27 changed files with 1147 additions and 1090 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.svn
|
|
@ -1,8 +0,0 @@
|
|||
pipeline:
|
||||
code-style:
|
||||
image: composer
|
||||
commands:
|
||||
- composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer
|
||||
- composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
|
||||
- composer global require digicomp/php-codesniffer:@dev
|
||||
- composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Migrations/ Tests/ Resources/Private/
|
|
@ -1,32 +0,0 @@
|
|||
workspace:
|
||||
base: /woodpecker
|
||||
path: package
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- FLOW_VERSION: 6.3
|
||||
PHP_VERSION: 7.4
|
||||
- FLOW_VERSION: 7.3
|
||||
PHP_VERSION: 7.4
|
||||
- FLOW_VERSION: 7.3
|
||||
PHP_VERSION: 8.2
|
||||
- FLOW_VERSION: 8.2
|
||||
PHP_VERSION: 8.2
|
||||
|
||||
pipeline:
|
||||
functional-tests:
|
||||
image: thecodingmachine/php:${PHP_VERSION}-v4-cli
|
||||
environment:
|
||||
# Enable the PDO_SQLITE extension
|
||||
- "PHP_EXTENSION_PDO_SQLITE=1"
|
||||
- "FLOW_VERSION=${FLOW_VERSION}"
|
||||
- "NEOS_BUILD_DIR=/woodpecker/Build-${FLOW_VERSION}"
|
||||
commands:
|
||||
- "sudo mkdir $NEOS_BUILD_DIR"
|
||||
- "sudo chown -R docker:docker $NEOS_BUILD_DIR"
|
||||
- "cd $NEOS_BUILD_DIR"
|
||||
- "composer create-project --no-install neos/flow-base-distribution:^$FLOW_VERSION ."
|
||||
- "composer config repositories.repo-name path /woodpecker/package"
|
||||
- "composer remove --dev --no-update neos/behat || composer remove --no-update neos/behat"
|
||||
- "composer require digicomp/settingvalidator:@dev"
|
||||
- "bin/phpunit --configuration Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/DigiComp.SettingValidator/Tests/Functional"
|
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,14 +0,0 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.0.1] - 2020-09-09
|
||||
### Changed
|
||||
- dependency to Flow ^6.3
|
||||
|
||||
## [3.0.0] - 2020-08-31
|
||||
Start of the changelog.
|
24
Classes/DigiComp/SettingValidator/Package.php
Normal file
24
Classes/DigiComp/SettingValidator/Package.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace DigiComp\SettingValidator;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||
use \TYPO3\Flow\Package\Package as BasePackage;
|
||||
|
||||
/**
|
||||
* @Flow\Scope("prototype")
|
||||
*/
|
||||
class Package extends BasePackage {
|
||||
|
||||
public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) {
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
$dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||
function(ConfigurationManager $configurationManager) {
|
||||
$configurationManager->registerConfigurationType('Validation', ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, TRUE);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
namespace DigiComp\SettingValidator\Validation\Validator;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||
use TYPO3\Flow\Reflection\ObjectAccess;
|
||||
use TYPO3\Flow\Reflection\ReflectionService;
|
||||
use TYPO3\Flow\Validation\Exception\InvalidValidationConfigurationException;
|
||||
use TYPO3\Flow\Validation\Exception\InvalidValidationOptionsException;
|
||||
use TYPO3\Flow\Validation\Validator\AbstractValidator;
|
||||
use TYPO3\Flow\Validation\ValidatorResolver;
|
||||
|
||||
/**
|
||||
* Validator resolving other Validators defined in Validation.yaml
|
||||
*
|
||||
* @Flow\Scope("prototype")
|
||||
*/
|
||||
class SettingsValidator extends AbstractValidator {
|
||||
|
||||
/**
|
||||
* @var ValidatorResolver
|
||||
* @Flow\Inject
|
||||
*/
|
||||
protected $validatorResolver;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $validations;
|
||||
|
||||
/**
|
||||
* @var \TYPO3\Flow\Configuration\ConfigurationManager
|
||||
*/
|
||||
protected $configurationManager;
|
||||
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
|
||||
$this->configurationManager = $configurationManager;
|
||||
$this->validations = $this->configurationManager->getConfiguration('Validation');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var ReflectionService
|
||||
* @Flow\Inject
|
||||
*/
|
||||
protected $reflectionService;
|
||||
|
||||
protected $supportedOptions = array(
|
||||
'name' => array('', 'Set the name of the setting-array to use', 'string', FALSE)
|
||||
);
|
||||
|
||||
/**
|
||||
* Check if $value is valid. If it is not valid, needs to add an error
|
||||
* to Result.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws InvalidValidationOptionsException
|
||||
* @throws InvalidValidationConfigurationException
|
||||
*/
|
||||
protected function isValid($value) {
|
||||
$name = $this->options['name'] ? $this->options['name'] : $this->reflectionService->getClassNameByObject($value);
|
||||
if (! isset($this->validations[$name])) {
|
||||
throw new InvalidValidationOptionsException('The name ' . $name . ' has not been defined in Validation.yaml!', 1397821438);
|
||||
}
|
||||
$config = &$this->validations[$name];
|
||||
foreach($config as $validatorConfig) {
|
||||
$validator = $this->validatorResolver->createValidator($validatorConfig['validator'], $validatorConfig['options']);
|
||||
if (!$validator) {
|
||||
throw new InvalidValidationConfigurationException('Validator could not be resolved: ' . $validatorConfig['validator'] . '. Check your validation.yaml', 1402326139);
|
||||
}
|
||||
if (isset($validatorConfig['property'])) {
|
||||
$this->result->forProperty($validatorConfig['property'])->merge($validator->validate(ObjectAccess::getPropertyPath($value, $validatorConfig['property'])));
|
||||
} else {
|
||||
$this->result->merge($validator->validate($value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
use Neos\Flow\Core\Bootstrap;
|
||||
use Neos\Flow\Package\Package as NeosFlowPackagePackage;
|
||||
|
||||
/**
|
||||
* Package base class of the DigiComp.SettingValidator package.
|
||||
*/
|
||||
class Package extends NeosFlowPackagePackage
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function boot(Bootstrap $bootstrap): void
|
||||
{
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
|
||||
$dispatcher->connect(
|
||||
ConfigurationManager::class,
|
||||
'configurationManagerReady',
|
||||
function (ConfigurationManager $configurationManager): void {
|
||||
$configurationManager->registerConfigurationType('Validation');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Validation\Validator;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Eel\EelEvaluatorInterface;
|
||||
use Neos\Eel\Exception as NeosEelException;
|
||||
use Neos\Eel\Utility;
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\Flow\ObjectManagement\DependencyInjection\DependencyProxy;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationConfigurationException;
|
||||
use Neos\Flow\Validation\Exception\NoSuchValidatorException;
|
||||
use Neos\Flow\Validation\Validator\AbstractValidator;
|
||||
use Neos\Flow\Validation\ValidatorResolver;
|
||||
|
||||
class ConditionalValidator extends AbstractValidator
|
||||
{
|
||||
/**
|
||||
* @Flow\Inject
|
||||
* @var EelEvaluatorInterface
|
||||
*/
|
||||
protected $eelEvaluator;
|
||||
|
||||
/**
|
||||
* @Flow\Inject
|
||||
* @var ValidatorResolver
|
||||
*/
|
||||
protected $validatorResolver;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $supportedOptions = [
|
||||
'conditions' => [[], 'List of entries with "condition" (eel expression) and "validators" (list of validators).', 'array', true],
|
||||
'fallbackValidators' => [[], 'List of validators that is used if no condition matched.', 'array'],
|
||||
'validationGroups' => [['Default'], 'Same as "Validation Groups" of Flow Framework', 'array'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws InvalidValidationConfigurationException
|
||||
* @throws NeosEelException
|
||||
* @throws NoSuchValidatorException
|
||||
*/
|
||||
protected function isValid($value): void
|
||||
{
|
||||
$validatorConfigs = [];
|
||||
|
||||
$hasMatch = false;
|
||||
|
||||
foreach ($this->options['conditions'] as $condition) {
|
||||
if ($this->eelEvaluator instanceof DependencyProxy) {
|
||||
$this->eelEvaluator->_activateDependency();
|
||||
}
|
||||
|
||||
if (!Utility::evaluateEelExpression($condition['condition'], $this->eelEvaluator, ['this' => $value])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hasMatch = true;
|
||||
|
||||
foreach ($condition['validators'] as $validator => $options) {
|
||||
if ($options === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$validatorConfigs[] = [
|
||||
'validator' => $validator,
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasMatch) {
|
||||
foreach ($this->options['fallbackValidators'] as $validator => $options) {
|
||||
if ($options === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$validatorConfigs[] = [
|
||||
'validator' => $validator,
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($validatorConfigs as $validatorConfig) {
|
||||
if (!$this->doesValidationGroupsMatch($validatorConfig)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->handleValidationGroups($validatorConfig);
|
||||
|
||||
$validator = $this->validatorResolver->createValidator(
|
||||
$validatorConfig['validator'],
|
||||
$validatorConfig['options']
|
||||
);
|
||||
|
||||
if ($validator === null) {
|
||||
throw new InvalidValidationConfigurationException(
|
||||
\sprintf(
|
||||
'Validator "%s" could not be resolved. Check your Validation.yaml',
|
||||
$validatorConfig['validator']
|
||||
),
|
||||
1402326139
|
||||
);
|
||||
}
|
||||
|
||||
$this->getResult()->merge($validator->validate($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether at least one configured group does match, if any is configured.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
* @return bool
|
||||
*/
|
||||
protected function doesValidationGroupsMatch(array $validatorConfig): bool
|
||||
{
|
||||
return !isset($validatorConfig['options']['validationGroups'])
|
||||
|| \array_intersect(
|
||||
$validatorConfig['options']['validationGroups'],
|
||||
$this->options['validationGroups']
|
||||
) !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add validation groups for recursion if necessary.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
*/
|
||||
protected function handleValidationGroups(array &$validatorConfig): void
|
||||
{
|
||||
if (\in_array($validatorConfig['validator'], ['DigiComp.SettingValidator:Settings', 'DigiComp.SettingValidator:Conditional', 'DigiComp.SettingValidator:Properties', 'Neos.Flow:Collection'])) {
|
||||
$validatorConfig['options']['validationGroups'] = $this->options['validationGroups'];
|
||||
} elseif (isset($validatorConfig['options']['validationGroups'])) {
|
||||
unset($validatorConfig['options']['validationGroups']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Validation\Validator;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationConfigurationException;
|
||||
use Neos\Flow\Validation\Exception\NoSuchValidatorException;
|
||||
use Neos\Flow\Validation\Validator\AbstractValidator;
|
||||
use Neos\Flow\Validation\ValidatorResolver;
|
||||
use Neos\Utility\ObjectAccess;
|
||||
|
||||
class PropertiesValidator extends AbstractValidator
|
||||
{
|
||||
/**
|
||||
* @Flow\Inject
|
||||
* @var ValidatorResolver
|
||||
*/
|
||||
protected $validatorResolver;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $supportedOptions = [
|
||||
'validatorsForProperties' => [[], 'List of validators for properties. ', 'array', true],
|
||||
'validationGroups' => [['Default'], 'Same as "Validation Groups" of Flow Framework', 'array'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws InvalidValidationConfigurationException
|
||||
* @throws NoSuchValidatorException
|
||||
*/
|
||||
protected function isValid($value): void
|
||||
{
|
||||
$validatorConfigs = [];
|
||||
|
||||
foreach ($this->options['validatorsForProperties'] as $property => $validators) {
|
||||
foreach ($validators as $validator => $options) {
|
||||
if ($options === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$validatorConfigs[] = [
|
||||
'validator' => $validator,
|
||||
'options' => $options,
|
||||
'property' => $property,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($validatorConfigs as $validatorConfig) {
|
||||
if (!$this->doesValidationGroupsMatch($validatorConfig)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->handleValidationGroups($validatorConfig);
|
||||
|
||||
$validator = $this->validatorResolver->createValidator(
|
||||
$validatorConfig['validator'],
|
||||
$validatorConfig['options']
|
||||
);
|
||||
|
||||
if ($validator === null) {
|
||||
throw new InvalidValidationConfigurationException(
|
||||
\sprintf(
|
||||
'Validator "%s" could not be resolved. Check your Validation.yaml',
|
||||
$validatorConfig['validator']
|
||||
),
|
||||
1402326139
|
||||
);
|
||||
}
|
||||
|
||||
$this->getResult()->forProperty($validatorConfig['property'])->merge(
|
||||
$validator->validate(ObjectAccess::getPropertyPath($value, $validatorConfig['property']))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether at least one configured group does match, if any is configured.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
* @return bool
|
||||
*/
|
||||
protected function doesValidationGroupsMatch(array $validatorConfig): bool
|
||||
{
|
||||
return !isset($validatorConfig['options']['validationGroups'])
|
||||
|| \array_intersect(
|
||||
$validatorConfig['options']['validationGroups'],
|
||||
$this->options['validationGroups']
|
||||
) !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add validation groups for recursion if necessary.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
*/
|
||||
protected function handleValidationGroups(array &$validatorConfig): void
|
||||
{
|
||||
if (\in_array($validatorConfig['validator'], ['DigiComp.SettingValidator:Settings', 'DigiComp.SettingValidator:Conditional', 'DigiComp.SettingValidator:Properties', 'Neos.Flow:Collection'])) {
|
||||
$validatorConfig['options']['validationGroups'] = $this->options['validationGroups'];
|
||||
} elseif (isset($validatorConfig['options']['validationGroups'])) {
|
||||
unset($validatorConfig['options']['validationGroups']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Validation\Validator;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationConfigurationException;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationOptionsException;
|
||||
use Neos\Flow\Validation\Exception\NoSuchValidatorException;
|
||||
use Neos\Flow\Validation\Validator\AbstractValidator;
|
||||
use Neos\Flow\Validation\ValidatorResolver;
|
||||
use Neos\Utility\TypeHandling;
|
||||
|
||||
/**
|
||||
* Validator resolving other Validators defined in Validation.yaml
|
||||
*/
|
||||
class SettingsValidator extends AbstractValidator
|
||||
{
|
||||
/**
|
||||
* @Flow\Inject
|
||||
* @var ValidatorResolver
|
||||
*/
|
||||
protected $validatorResolver;
|
||||
|
||||
/**
|
||||
* @Flow\InjectConfiguration(type="Validation")
|
||||
* @var array
|
||||
*/
|
||||
protected array $validations;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $supportedOptions = [
|
||||
'name' => ['', 'Name of the setting array to use', 'string'],
|
||||
'validationGroups' => [['Default'], 'Same as "Validation Groups" of Flow Framework', 'array'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws InvalidValidationOptionsException
|
||||
* @throws InvalidValidationConfigurationException
|
||||
* @throws NoSuchValidatorException
|
||||
*/
|
||||
protected function isValid($value): void
|
||||
{
|
||||
$validations = $this->validations;
|
||||
|
||||
// TODO: feature idea - we could extend the library to automatically be part of the base conjunction validator
|
||||
$name = $this->options['name'] !== '' ? $this->options['name'] : TypeHandling::getTypeForValue($value);
|
||||
if (!isset($validations[$name])) {
|
||||
throw new InvalidValidationOptionsException(
|
||||
'The name "' . $name . '" has not been defined in Validation.yaml!',
|
||||
1397821438
|
||||
);
|
||||
}
|
||||
|
||||
// @deprecated - converts old "self" to new structure
|
||||
if (isset($validations[$name]['self'])) {
|
||||
foreach ($validations[$name]['self'] as $validator => $options) {
|
||||
if (isset($validations[$name][$validator])) {
|
||||
throw new \RuntimeException('The validator "' . $validator . '" is already defined on parent level.', 1725000364);
|
||||
}
|
||||
$validations[$name][$validator] = $options;
|
||||
}
|
||||
|
||||
unset($validations[$name]['self']);
|
||||
}
|
||||
|
||||
// @deprecated - converts old "properties" to new structure
|
||||
if (isset($validations[$name]['properties'])) {
|
||||
if (isset($validations[$name]['DigiComp.SettingValidator:Properties'])) {
|
||||
throw new \RuntimeException('The validator "DigiComp.SettingValidator:Properties" is already defined on parent level.', 1725000396);
|
||||
}
|
||||
$validations[$name]['DigiComp.SettingValidator:Properties'] = [
|
||||
'validatorsForProperties' => $validations[$name]['properties'],
|
||||
];
|
||||
|
||||
unset($validations[$name]['properties']);
|
||||
}
|
||||
|
||||
$validatorConfigs = [];
|
||||
|
||||
foreach ($validations[$name] as $validator => $options) {
|
||||
if ($options === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$validatorConfigs[] = [
|
||||
'validator' => $validator,
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($validatorConfigs as $validatorConfig) {
|
||||
if (!$this->doesValidationGroupsMatch($validatorConfig)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->handleValidationGroups($validatorConfig);
|
||||
|
||||
$validator = $this->validatorResolver->createValidator(
|
||||
$validatorConfig['validator'],
|
||||
$validatorConfig['options']
|
||||
);
|
||||
|
||||
if ($validator === null) {
|
||||
throw new InvalidValidationConfigurationException(
|
||||
\sprintf(
|
||||
'Validator "%s" could not be resolved. Check your Validation.yaml',
|
||||
$validatorConfig['validator']
|
||||
),
|
||||
1402326139
|
||||
);
|
||||
}
|
||||
|
||||
$this->getResult()->merge($validator->validate($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether at least one configured group does match, if any is configured.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
* @return bool
|
||||
*/
|
||||
protected function doesValidationGroupsMatch(array $validatorConfig): bool
|
||||
{
|
||||
return !isset($validatorConfig['options']['validationGroups'])
|
||||
|| \array_intersect(
|
||||
$validatorConfig['options']['validationGroups'],
|
||||
$this->options['validationGroups']
|
||||
) !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add validation groups for recursion if necessary.
|
||||
*
|
||||
* @param array $validatorConfig
|
||||
*/
|
||||
protected function handleValidationGroups(array &$validatorConfig): void
|
||||
{
|
||||
if (\in_array($validatorConfig['validator'], ['DigiComp.SettingValidator:Settings', 'DigiComp.SettingValidator:Conditional', 'DigiComp.SettingValidator:Properties', 'Neos.Flow:Collection'])) {
|
||||
$validatorConfig['options']['validationGroups'] = $this->options['validationGroups'];
|
||||
} elseif (isset($validatorConfig['options']['validationGroups'])) {
|
||||
unset($validatorConfig['options']['validationGroups']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject:
|
||||
properties:
|
||||
shouldBeTrue:
|
||||
BooleanValue:
|
||||
expectedValue: true
|
||||
shouldBeFalse:
|
||||
BooleanValue:
|
||||
expectedValue: false
|
||||
Grumble: ~
|
||||
|
||||
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsCustomObject:
|
||||
self:
|
||||
DigiComp.SettingValidator:Settings:
|
||||
name: "GroupValidatorCustom"
|
||||
|
||||
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsDefaultObject:
|
||||
self:
|
||||
DigiComp.SettingValidator:Settings:
|
||||
name: "GroupValidatorDefault"
|
||||
|
||||
GroupValidatorDefault:
|
||||
properties:
|
||||
shouldBeTrue:
|
||||
BooleanValue:
|
||||
expectedValue: true
|
||||
|
||||
GroupValidatorCustom:
|
||||
properties:
|
||||
shouldBeFalse:
|
||||
BooleanValue:
|
||||
expectedValue: false
|
||||
validationGroups:
|
||||
- "Custom"
|
||||
|
||||
TrueValidator:
|
||||
self:
|
||||
BooleanValue:
|
||||
expectedValue: true
|
1
Documentation/.gitignore
vendored
Normal file
1
Documentation/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build
|
225
Documentation/Makefile
Normal file
225
Documentation/Makefile
Normal file
|
@ -0,0 +1,225 @@
|
|||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = build
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " applehelp to make an Apple Help Book"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " epub3 to make an epub3"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
@echo " coverage to run coverage check of the documentation (if enabled)"
|
||||
@echo " dummy to check syntax errors of document sources"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
.PHONY: html
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
.PHONY: dirhtml
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
.PHONY: singlehtml
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
.PHONY: pickle
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
.PHONY: json
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
.PHONY: htmlhelp
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
.PHONY: qthelp
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DigiCompSettingValidator.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DigiCompSettingValidator.qhc"
|
||||
|
||||
.PHONY: applehelp
|
||||
applehelp:
|
||||
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
||||
@echo
|
||||
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
|
||||
@echo "N.B. You won't be able to view it unless you put it in" \
|
||||
"~/Library/Documentation/Help or install it in your application" \
|
||||
"bundle."
|
||||
|
||||
.PHONY: devhelp
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/DigiCompSettingValidator"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/DigiCompSettingValidator"
|
||||
@echo "# devhelp"
|
||||
|
||||
.PHONY: epub
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
.PHONY: epub3
|
||||
epub3:
|
||||
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
|
||||
@echo
|
||||
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
|
||||
|
||||
.PHONY: latex
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
.PHONY: latexpdf
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
.PHONY: latexpdfja
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
.PHONY: text
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
.PHONY: man
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
.PHONY: texinfo
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
.PHONY: info
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
.PHONY: gettext
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
.PHONY: changes
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
.PHONY: linkcheck
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
.PHONY: doctest
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
.PHONY: coverage
|
||||
coverage:
|
||||
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
|
||||
@echo "Testing of coverage in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/coverage/python.txt."
|
||||
|
||||
.PHONY: xml
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
.PHONY: pseudoxml
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
|
||||
.PHONY: dummy
|
||||
dummy:
|
||||
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
|
||||
@echo
|
||||
@echo "Build finished. Dummy builder generates no files."
|
281
Documentation/make.bat
Normal file
281
Documentation/make.bat
Normal file
|
@ -0,0 +1,281 @@
|
|||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% source
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. singlehtml to make a single large HTML file
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. devhelp to make HTML files and a Devhelp project
|
||||
echo. epub to make an epub
|
||||
echo. epub3 to make an epub3
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. text to make text files
|
||||
echo. man to make manual pages
|
||||
echo. texinfo to make Texinfo files
|
||||
echo. gettext to make PO message catalogs
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. xml to make Docutils-native XML files
|
||||
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
echo. coverage to run coverage check of the documentation if enabled
|
||||
echo. dummy to check syntax errors of document sources
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
REM Check if sphinx-build is available and fallback to Python version if any
|
||||
%SPHINXBUILD% 1>NUL 2>NUL
|
||||
if errorlevel 9009 goto sphinx_python
|
||||
goto sphinx_ok
|
||||
|
||||
:sphinx_python
|
||||
|
||||
set SPHINXBUILD=python -m sphinx.__init__
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:sphinx_ok
|
||||
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "singlehtml" (
|
||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\DigiCompSettingValidator.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\DigiCompSettingValidator.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "devhelp" (
|
||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub" (
|
||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub3" (
|
||||
%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub3 file is in %BUILDDIR%/epub3.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdf" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf
|
||||
cd %~dp0
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdfja" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf-ja
|
||||
cd %~dp0
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "text" (
|
||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "man" (
|
||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "texinfo" (
|
||||
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "gettext" (
|
||||
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "coverage" (
|
||||
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of coverage in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/coverage/python.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "xml" (
|
||||
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pseudoxml" (
|
||||
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dummy" (
|
||||
%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. Dummy builder generates no files.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
351
Documentation/source/conf.py
Normal file
351
Documentation/source/conf.py
Normal file
|
@ -0,0 +1,351 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# DigiComp.SettingValidator documentation build configuration file, created by
|
||||
# sphinx-quickstart on Fri Jul 15 17:46:40 2016.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'DigiComp.SettingValidator'
|
||||
copyright = u'2016, Ferdinand Kuhl'
|
||||
author = u'Ferdinand Kuhl'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'1.0.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'1.0.3'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#
|
||||
# today = ''
|
||||
#
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
# keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||
import sphinx_rtd_theme
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents.
|
||||
# "<project> v<release> documentation" by default.
|
||||
#
|
||||
# html_title = u'DigiComp.SettingValidator v1.0.3'
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (relative to this directory) to use as a favicon of
|
||||
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#
|
||||
# html_extra_path = []
|
||||
|
||||
# If not None, a 'Last updated on:' timestamp is inserted at every page
|
||||
# bottom, using the given strftime format.
|
||||
# The empty string is equivalent to '%b %d, %Y'.
|
||||
#
|
||||
# html_last_updated_fmt = None
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
# html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
|
||||
#
|
||||
# html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# 'ja' uses this config value.
|
||||
# 'zh' user can custom change `jieba` dictionary path.
|
||||
#
|
||||
# html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#
|
||||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'DigiCompSettingValidatordoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'DigiCompSettingValidator.tex', u'DigiComp.SettingValidator Documentation',
|
||||
u'Ferdinand Kuhl', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'digicompsettingvalidator', u'DigiComp.SettingValidator Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'DigiCompSettingValidator', u'DigiComp.SettingValidator Documentation',
|
||||
author, 'DigiCompSettingValidator', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
### Allow inline php highlighting
|
||||
# load PhpLexer
|
||||
from sphinx.highlighting import lexers
|
||||
from pygments.lexers.web import PhpLexer
|
||||
# enable highlighting for PHP code not between <?php ... ?> by default
|
||||
lexers['php'] = PhpLexer(startinline=True)
|
||||
lexers['php-annotations'] = PhpLexer(startinline=True)
|
||||
### Allow inline php highlighting
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
23
Documentation/source/examples/Validation.yaml
Normal file
23
Documentation/source/examples/Validation.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
SuperVendor\SuperPackage\Domain\Model\Order:
|
||||
-
|
||||
property: price
|
||||
validator: NumberRange
|
||||
options:
|
||||
maximum: 20
|
||||
minimum: 10
|
||||
-
|
||||
validator: SuperVendor.SuperPackage:SomeOtherValidator #validates the complete object
|
||||
options: []
|
||||
-
|
||||
property: customer
|
||||
validator: DigiComp.SettingValidator:Settings
|
||||
options:
|
||||
name: OrderCustomer
|
||||
|
||||
OrderCustomer:
|
||||
-
|
||||
property: firstName
|
||||
validator: StringLength
|
||||
options:
|
||||
minimum: 3
|
||||
maximum: 20
|
34
Documentation/source/index.rst
Normal file
34
Documentation/source/index.rst
Normal file
|
@ -0,0 +1,34 @@
|
|||
.. highlight:: php
|
||||
.. DigiComp.SettingValidator documentation master file, created by
|
||||
sphinx-quickstart on Fri Jul 15 17:46:40 2016.
|
||||
|
||||
Welcome to DigiComp.SettingValidator's documentation!
|
||||
=====================================================
|
||||
|
||||
This Package allows to configure Validators for your Action-Arguments or domain model properties to be set by a new
|
||||
Yaml-File in your Configuration directory.
|
||||
|
||||
Lets imagine you have this action-method::
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings", argumentName="$order")
|
||||
*/
|
||||
public function createOrder(Order $order) {...}
|
||||
|
||||
Then your :file:`Validation.yaml` can look like this:
|
||||
|
||||
.. literalinclude:: /examples/Validation.yaml
|
||||
:lines: 1-15
|
||||
|
||||
As you see: Nesting is possible ;) That way you can easily construct flexible structures.
|
||||
|
||||
The SettingsValidator has an optional option: ``name`` - If you don't give one, it assumes your validation value is an
|
||||
object and searches in :file:`Validation.yaml` for the FQCN.
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
usage
|
74
Documentation/source/usage.rst
Normal file
74
Documentation/source/usage.rst
Normal file
|
@ -0,0 +1,74 @@
|
|||
.. highlight:: php
|
||||
.. _usage:
|
||||
|
||||
Place of configuration
|
||||
======================
|
||||
|
||||
The package introduces a new configuration type ``Validation``. The configuration is done through
|
||||
:file:`Validation.yaml` files.
|
||||
|
||||
``allowSplitSource`` is set to true, so it's possible to split large files into smaller ones by
|
||||
calling them like :file:`Validation.Users.yaml`.
|
||||
|
||||
.. _types-of-configuration:
|
||||
|
||||
Types of configuration
|
||||
======================
|
||||
|
||||
You can define the validation rules either for a fully qualified class name, or a custom name.
|
||||
|
||||
Given the following :file:`Validation.yaml`:
|
||||
|
||||
.. literalinclude:: /examples/Validation.yaml
|
||||
|
||||
One class is configured by it's fully qualified class name
|
||||
``SuperVendor\SuperPackage\Domain\Model\Order`` and a custom name is configured ``OrderCustomer``.
|
||||
|
||||
.. _types-of-configuration-custom-name:
|
||||
|
||||
Custom Name
|
||||
-----------
|
||||
|
||||
If you prefer the name, you have to configure the validator to use the specific name::
|
||||
|
||||
/**
|
||||
* @param OrderCustomer $orderCustomer
|
||||
* @Flow\Validate(argumentName="$orderCustomer", type="DigiComp.SettingValidator:Settings", options={"name"="OrderCustomer"})
|
||||
*/
|
||||
public function createOrder(OrderCustomer $orderCustomer) {...}
|
||||
|
||||
.. _types-of-configuration-fqcn:
|
||||
|
||||
Fully qualified class namespace
|
||||
-------------------------------
|
||||
|
||||
If you provide the fully qualified class name, you don't have to provide the additional
|
||||
argument, the following code will be enough::
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @Flow\Validate(argumentName="$order, type="DigiComp.SettingValidator:Settings")
|
||||
*/
|
||||
public function createOrder(Order $order) {...}
|
||||
|
||||
.. _structure-of-configuration:
|
||||
|
||||
Structure of configuration
|
||||
==========================
|
||||
|
||||
Each configured validation consist of an array with validation settings.
|
||||
Each entry needs at least the following options:
|
||||
|
||||
``validator``
|
||||
The Validator to use, the same way you would use in usual way.
|
||||
E.g. use short names for Framework validators like ``StringLength`` or full path for custom
|
||||
validators like ``DigiComp.SettingValidator:Settings``.
|
||||
``options``
|
||||
An array of options to provide for the validator.
|
||||
The same as you would have done through the usual way.
|
||||
If the validator doesn't take arguments, provide an empty array.
|
||||
|
||||
Also there are some optional options:
|
||||
|
||||
``property``
|
||||
Optional, used to configure validation for a property of the object the validation is applied to.
|
|
@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE.
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Neos\Flow\Core\Migrations;
|
||||
|
||||
/**
|
||||
* Restructures all Validation.yaml to new format
|
||||
*/
|
||||
class Version20170603120900 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIdentifier(): string
|
||||
{
|
||||
return 'DigiComp.SettingValidator-20170603120900';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$this->processConfiguration(
|
||||
'Validation',
|
||||
function (array &$configuration): void {
|
||||
foreach ($configuration as $validatorName => &$validators) {
|
||||
// guard that protects configuration, which has already the new format:
|
||||
if (isset($validators['properties']) || isset($validators['self'])) {
|
||||
continue;
|
||||
}
|
||||
$newConfiguration = ['properties' => [], 'self' => []];
|
||||
|
||||
foreach ($validators as $key => $validator) {
|
||||
if (!isset($validator['validator']) || !isset($validator['options'])) {
|
||||
$this->showWarning(
|
||||
'The Validation.yaml files contained no validator or options for validation: '
|
||||
. '"' . $validatorName . '.' . $key . '". It was not migrated.'
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (isset($validator['property'])) {
|
||||
$newConfiguration['properties'][$validator['property']][$validator['validator']] =
|
||||
$validator['options'];
|
||||
} else {
|
||||
$newConfiguration['self'][$validator['validator']] = $validator['options'];
|
||||
}
|
||||
}
|
||||
$validators = $newConfiguration;
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
241
README.md
241
README.md
|
@ -1,211 +1,46 @@
|
|||
# DigiComp.SettingValidator
|
||||
DigiComp.SettingValidator
|
||||
-------------------------
|
||||
|
||||
This package allows configuring validators with a new configuration type.
|
||||
|
||||
## Introduction
|
||||
This Package allows to configure Validators for your Action-Arguments or domain model properties to be set by a new
|
||||
Yaml-File in your Configuration directory.
|
||||
|
||||
This package provides the `SettingsValidator` which uses the configuration type `Validation` to resolve the validators
|
||||
that should be applied to the value. It distinguishes between validators that are applied to the value itself and its
|
||||
properties.
|
||||
Lets imagine you had this action-method:
|
||||
|
||||
## Resolving the validation configuration
|
||||
/**
|
||||
* @param Order $order
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings", argumentName="$order")
|
||||
*/
|
||||
public function createOrder($order) {...}
|
||||
|
||||
The `SettingsValidator` has an option `name`. If it is set, the name is used to resolve the validation configuration,
|
||||
otherwise the type of the value is used, which is mainly useful for objects where the FQCN is used.
|
||||
Then your Validation.yaml could look like this:
|
||||
|
||||
### Resolving by option `name`
|
||||
SuperVendor\SuperPackage\Domain\Model\Order:
|
||||
-
|
||||
property: price
|
||||
validator: NumberRange
|
||||
options:
|
||||
maximum: 20
|
||||
minimum: 10
|
||||
-
|
||||
validator: SuperVendor.SuperPackage:SomeOtherValidator #validates the complete object
|
||||
options: []
|
||||
-
|
||||
property: customer
|
||||
validator: DigiComp.SettingValidator:Settings
|
||||
options:
|
||||
name: OrderCustomer
|
||||
|
||||
OrderCustomer:
|
||||
-
|
||||
property: firstName
|
||||
validator: StringLength
|
||||
options:
|
||||
minimum: 3
|
||||
maximum: 20
|
||||
|
||||
|
||||
To resolve the validation configuration by name just use the option `name`.
|
||||
As you see: Nesting is possible ;) That way you can easily construct flexible structures.
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings", options={"name"="MyNamedValidator"})
|
||||
* @var MyObject
|
||||
*/
|
||||
protected MyObject $myObject;
|
||||
```
|
||||
|
||||
The `SettingsValidator` will search for an entry inside the `Validation.yaml` with that name.
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
...
|
||||
```
|
||||
|
||||
### Resolving by type
|
||||
|
||||
To resolve the validation configuration by type just do not set the option `name`.
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings")
|
||||
* @var MyObject
|
||||
*/
|
||||
protected MyObject $myObject;
|
||||
```
|
||||
|
||||
The `SettingsValidator` will search for an entry inside the `Validation.yaml` with the FQCN of `MyObject`.
|
||||
|
||||
```yaml
|
||||
My\Package\Domain\Model\MyObject:
|
||||
...
|
||||
```
|
||||
|
||||
## The validation configuration
|
||||
|
||||
### Difference between `self` and `properties`
|
||||
|
||||
`self` contains a map of validators that are applied to the value itself. `properties` contains a map with property
|
||||
names of the value you would like to validate and each entry contains a map of validators that are applied to that
|
||||
property.
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
self:
|
||||
...
|
||||
properties:
|
||||
myProperty1:
|
||||
...
|
||||
myProperty2:
|
||||
...
|
||||
```
|
||||
|
||||
### Configuring a validator
|
||||
|
||||
To configure a validator you use the type of the validator as key and the options as entries of that key. If the
|
||||
validator has no options or all the default values are used, set an empty map as options.
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
self:
|
||||
'My.Package:SomeValidator':
|
||||
myOption: "myOptionValue"
|
||||
properties:
|
||||
myProperty1:
|
||||
'My.Package:SomeOtherValidator': {}
|
||||
myProperty2:
|
||||
'My.Package:SomeOtherValidator': {}
|
||||
```
|
||||
|
||||
### Disable a validator
|
||||
|
||||
To disable a validator you need to set the options to `null`.
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
self:
|
||||
'My.Package:SomeValidator': ~
|
||||
```
|
||||
|
||||
## Using the `SettingsValidator`
|
||||
|
||||
The `SettingsValidator` can be used to reduce the number of `@Flow\Validate` annotations and gives you the possibility
|
||||
of overwriting existing validation configurations in other packages.
|
||||
|
||||
### Using on properties
|
||||
|
||||
Old PHP code:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(type="My.Package:SomeValidator", options={"myOption"="myOptionValue"})
|
||||
* @Flow\Validate(type="My.Package:SomeOtherValidator")
|
||||
* @var MyObject
|
||||
*/
|
||||
protected MyObject $myObject;
|
||||
```
|
||||
|
||||
New PHP code:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings", options={"name"="MyNamedValidator"})
|
||||
* @var MyObject
|
||||
*/
|
||||
protected MyObject $myObject;
|
||||
```
|
||||
|
||||
New validation configuration:
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
self:
|
||||
'My.Package:SomeValidator':
|
||||
myOption: "myOptionValue"
|
||||
'My.Package:SomeOtherValidator': {}
|
||||
```
|
||||
|
||||
### Using on actions
|
||||
|
||||
Old PHP code:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(argumentName="myObject", type="My.Package:SomeValidator", options={"myOption"="myOptionValue"})
|
||||
* @Flow\Validate(argumentName="myObject", type="My.Package:SomeOtherValidator")
|
||||
* @param MyObject $myObject
|
||||
*/
|
||||
public function myAction(MyObject $myObject)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
New PHP code:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(argumentName="myObject", type="DigiComp.SettingValidator:Settings", options={"name"="MyNamedValidator"})
|
||||
* @param MyObject $myObject
|
||||
*/
|
||||
public function myAction(MyObject $myObject)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
New validation configuration:
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
self:
|
||||
'My.Package:SomeValidator':
|
||||
myOption: "myOptionValue"
|
||||
'My.Package:SomeOtherValidator': {}
|
||||
```
|
||||
|
||||
### Using inside validator configurations
|
||||
|
||||
You can use the `SettingsValidator` inside the validator configuration to easily construct flexible structures.
|
||||
|
||||
```yaml
|
||||
MyNamedValidator:
|
||||
properties:
|
||||
myProperty1:
|
||||
'DigiComp.SettingValidator:Settings':
|
||||
name: "MyOtherNamedValidator"
|
||||
|
||||
MyOtherNamedValidator:
|
||||
self:
|
||||
'My.Package:SomeOtherValidator': {}
|
||||
```
|
||||
|
||||
## Providing an empty validator
|
||||
|
||||
It can be useful to provide an empty validator in code that is used by many projects. By doing so you can make sure that
|
||||
a different validation is possible in any project.
|
||||
|
||||
```php
|
||||
/**
|
||||
* @Flow\Validate(argumentName="myObject", type="DigiComp.SettingValidator:Settings", options={"name"="MyNamedValidator"})
|
||||
* @param MyObject $myObject
|
||||
*/
|
||||
public function myAction(MyObject $myObject)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
```yaml
|
||||
MyNamedValidator: {}
|
||||
```
|
||||
The SettingsValidator has an optional option: "name" - If you don't give one, it assumes your validation value is an
|
||||
object and searches in Validation.yaml for the FQCN.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
type: "dictionary"
|
||||
additionalProperties:
|
||||
type: "dictionary"
|
||||
additionalProperties: false
|
||||
properties:
|
||||
type: "dictionary"
|
||||
additionalProperties: false
|
||||
properties:
|
||||
type: "dictionary"
|
||||
self:
|
||||
type: "dictionary"
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
|
||||
class TestObject
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeTrue = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeFalse = true;
|
||||
|
||||
/**
|
||||
* @Flow\Validate(type="DigiComp.SettingValidator:Settings", options={"name"="TrueValidator"})
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeTrueAndValidatedByAnnotation = false;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeTrue(): bool
|
||||
{
|
||||
return $this->shouldBeTrue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeFalse(): bool
|
||||
{
|
||||
return $this->shouldBeFalse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeTrueAndValidatedByAnnotation(): bool
|
||||
{
|
||||
return $this->shouldBeTrueAndValidatedByAnnotation;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
|
||||
|
||||
class TestValidationGroupsCustomObject
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeTrue = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeFalse = true;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeTrue(): bool
|
||||
{
|
||||
return $this->shouldBeTrue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeFalse(): bool
|
||||
{
|
||||
return $this->shouldBeFalse;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
|
||||
|
||||
class TestValidationGroupsDefaultObject
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeTrue = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $shouldBeFalse = true;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeTrue(): bool
|
||||
{
|
||||
return $this->shouldBeTrue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShouldBeFalse(): bool
|
||||
{
|
||||
return $this->shouldBeFalse;
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DigiComp\SettingValidator\Tests\Functional;
|
||||
|
||||
use DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject;
|
||||
use DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsCustomObject;
|
||||
use DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsDefaultObject;
|
||||
use DigiComp\SettingValidator\Validation\Validator\SettingsValidator;
|
||||
use Neos\Flow\Tests\FunctionalTestCase;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationConfigurationException;
|
||||
use Neos\Flow\Validation\Exception\InvalidValidationOptionsException;
|
||||
use Neos\Flow\Validation\Exception\NoSuchValidatorException;
|
||||
use Neos\Flow\Validation\ValidatorResolver;
|
||||
|
||||
class SettingsValidatorTest extends FunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @throws InvalidValidationOptionsException
|
||||
*/
|
||||
public function ifNoNameIsGivenClassNameIsUsed(): void
|
||||
{
|
||||
$result = $this->objectManager->get(SettingsValidator::class)->validate(new TestObject());
|
||||
|
||||
self::assertTrue($result->hasErrors());
|
||||
self::assertCount(1, $result->getFlattenedErrors());
|
||||
self::assertCount(1, $result->forProperty('shouldBeFalse')->getErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws InvalidValidationConfigurationException
|
||||
* @throws InvalidValidationOptionsException
|
||||
* @throws NoSuchValidatorException
|
||||
*/
|
||||
public function conjunctionValidationWorksAsExpected(): void
|
||||
{
|
||||
$result = $this->objectManager
|
||||
->get(ValidatorResolver::class)
|
||||
->getBaseValidatorConjunction(TestObject::class)
|
||||
->validate(new TestObject());
|
||||
|
||||
self::assertTrue($result->hasErrors());
|
||||
self::assertCount(1, $result->getFlattenedErrors());
|
||||
self::assertCount(1, $result->forProperty('shouldBeTrueAndValidatedByAnnotation')->getErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws InvalidValidationOptionsException
|
||||
*/
|
||||
public function defaultValidationGroupWorks(): void
|
||||
{
|
||||
$result = $this->objectManager
|
||||
->get(SettingsValidator::class, ['validationGroups' => ['Default']])
|
||||
->validate(new TestValidationGroupsDefaultObject());
|
||||
|
||||
self::assertTrue($result->hasErrors(), 'No errors for validation group "Default"');
|
||||
self::assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Default"');
|
||||
self::assertCount(1, $result->forProperty('shouldBeTrue')->getErrors(), 'Got no error for property');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws InvalidValidationOptionsException
|
||||
*/
|
||||
public function customValidationGroupWorks(): void
|
||||
{
|
||||
$result = $this->objectManager
|
||||
->get(SettingsValidator::class, ['validationGroups' => ['Custom']])
|
||||
->validate(new TestValidationGroupsCustomObject());
|
||||
|
||||
self::assertTrue($result->hasErrors(), 'No errors for validation group "Custom"');
|
||||
self::assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Custom"');
|
||||
self::assertCount(1, $result->forProperty('shouldBeFalse')->getErrors(), 'Got no error for property');
|
||||
}
|
||||
}
|
|
@ -1,54 +1,33 @@
|
|||
{
|
||||
"name": "digicomp/settingvalidator",
|
||||
"description": "Just a Neos\\Flow Validator resolving other Validators with Configuration/Validation.yaml",
|
||||
"type": "neos-package",
|
||||
"keywords": [
|
||||
"Neos",
|
||||
"Flow",
|
||||
"validation"
|
||||
],
|
||||
"homepage": "https://github.com/digital-competence/DigiComp.SettingValidator",
|
||||
"license": "MIT",
|
||||
"type": "typo3-flow-package",
|
||||
"description": "Just a TYPO3\\Flow Validator resolving other Validators with Configuration/Validation.yaml",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ferdinand Kuhl",
|
||||
"email": "f.kuhl@digital-competence.de",
|
||||
"homepage": "https://www.digital-competence.de",
|
||||
"homepage": "http://www.digital-competence.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/fcool/DigiComp.SettingValidator",
|
||||
"keywords": [
|
||||
"Flow",
|
||||
"validation"
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"neos/flow": "^6.3.5 || ^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikey179/vfsstream": "^1.6.1",
|
||||
"neos/buildessentials": "^7.0.0",
|
||||
"phpunit/phpunit": "~8.5",
|
||||
"vimeo/psalm": "~4.22.0"
|
||||
"typo3/flow": "~2.0|~3.0",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DigiComp\\SettingValidator\\": "Classes/"
|
||||
"psr-0": {
|
||||
"DigiComp\\SettingValidator": "Classes"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"DigiComp\\SettingValidator\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"platform-check": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "3.2.x-dev",
|
||||
"dev-version/2.x-dev": "2.1.x-dev",
|
||||
"dev-version/1.x-dev": "1.0.x-dev"
|
||||
},
|
||||
"neos": {
|
||||
"package-key": "DigiComp.SettingValidator"
|
||||
"dev-master": "1.0.x-dev"
|
||||
},
|
||||
"applied-flow-migrations": [
|
||||
"Inwebs.Basket-201409170938",
|
||||
|
@ -65,26 +44,7 @@
|
|||
"TYPO3.Fluid-20141113120800",
|
||||
"TYPO3.Flow-20141113121400",
|
||||
"TYPO3.Fluid-20141121091700",
|
||||
"TYPO3.Fluid-20150214130800",
|
||||
"TYPO3.Flow-20151113161300",
|
||||
"TYPO3.Flow-20161115140400",
|
||||
"TYPO3.Flow-20161115140430",
|
||||
"Neos.Flow-20161124204700",
|
||||
"Neos.Flow-20161124204701",
|
||||
"Neos.Flow-20161124224015",
|
||||
"Neos.Eel-20161124230101",
|
||||
"Neos.Imagine-20161124231742",
|
||||
"Neos.Media-20161124233100",
|
||||
"Neos.Flow-20161125124112",
|
||||
"Neos.SwiftMailer-20161130105617",
|
||||
"TYPO3.FluidAdaptor-20161130112935",
|
||||
"Neos.Media-20161219094126",
|
||||
"Neos.Flow-20170125103800",
|
||||
"Neos.Flow-20170127183102",
|
||||
"DigiComp.SettingValidator-20170603120900",
|
||||
"Neos.Flow-20180415105700",
|
||||
"Neos.Flow-20190425144900",
|
||||
"Neos.Flow-20190515215000"
|
||||
"TYPO3.Fluid-20150214130800"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue