diff --git a/Classes/Traits/ValidationTrait.php b/Classes/Traits/ValidationTrait.php index 3803181..b53f47b 100644 --- a/Classes/Traits/ValidationTrait.php +++ b/Classes/Traits/ValidationTrait.php @@ -52,28 +52,33 @@ trait ValidationTrait $flatten = new Flatten(); $schemaFlat = $flatten->flattenToArray($schema); $typesList = []; + $formatsList = []; foreach ($schemaFlat as $index => $row) { + $dataIndex = preg_replace( + '/(\.)(properties\.|items\.)/', + '$1', + $index + ); + $dataIndex = preg_replace( + '/^properties\./', + '', + $dataIndex + ); + $dataIndex = preg_replace( + '/\.(type|format)$/', + '', + $dataIndex + ); if (substr($index, -5) == '.type') { - $dataIndex = preg_replace( - '/(\.)(properties\.|items\.)/', - '$1', - $index - ); - $dataIndex = preg_replace( - '/^properties\./', - '', - $dataIndex - ); - $dataIndex = preg_replace( - '/\.type$/', - '', - $dataIndex - ); $typesList[$dataIndex] = $row; } + if (substr($index, -7) == '.format') { + $formatsList[$dataIndex] = $row; + } } foreach ($input as $index => $row) { $rowType = $typesList[$index]; + $formatType = $formatsList[$index]; if (!$rowType) { continue; } @@ -92,6 +97,16 @@ trait ValidationTrait if ($testResult === true || $testResult === false) { $input[$index] = $testResult; } + case 'string': + switch ($formatType) { + case 'date': + $row = \DateTime::createFromFormat( + 'Y-m-d H:i:s', + $row . ' 00:00:00', + ); + break; + } + break; } } return $input; diff --git a/composer.json.orig b/composer.json.orig new file mode 100644 index 0000000..abf0a9e --- /dev/null +++ b/composer.json.orig @@ -0,0 +1,33 @@ +{ + "name": "cjel/templates-aide", + "type": "typo3-cms-extension", + "description": "", + "authors": [ + { + "name": "Philipp Dieter", + "role": "Developer" + } + ], + "require": { +<<<<<<< HEAD + "typo3/cms-core": "8.7.0 - 9.5.99", + "sarhan/php-flatten": "^4.0" +======= + "typo3/cms-core": "8.7.0 - 10.99.99" +>>>>>>> 4a4b809d13bd33b85d84f03eba5edb603d74abfb + }, + "autoload": { + "psr-4": { + "Cjel\\TemplatesAide\\": "Classes" + } + }, + "autoload-dev": { + "psr-4": { + "Cjel\\TemplatesAide\\Tests\\": "Tests" + } + }, + "replace": { + "templates_aide": "self.version", + "typo3-ter/templates-aide": "self.version" + } +}