diff --git a/DataStorage/Database/tableDefinition.json b/DataStorage/Database/tableDefinition.json index 146fc36ad..4ba1e7fab 100644 --- a/DataStorage/Database/tableDefinition.json +++ b/DataStorage/Database/tableDefinition.json @@ -1,16 +1,19 @@ { - "name": "[a-z]+", - "fields": { - ".*": { - "name": "[a-z]+", - "type": ".+", - ".*?default": "1|0", - ".*?null": "1|0", - ".*?primary": "1|0", - ".*?unique": "1|0", - ".*?autoincrement": "1|0", - ".*?foreignTable": "[a-z]+", - ".*?foreignKey": "[a-z]+" + ".*": { + "name": "[a-z\\_]+", + "fields": { + ".*": { + "name": "[a-z\\_]+", + "type": "[A-Z0-9\\(\\)]+", + ".*?default": ".*", + ".*?null": "1|0", + ".*?primary": "1|0", + ".*?unique": "1|0", + ".*?autoincrement": "1|0", + ".*?foreignTable": "[a-z\\_]+", + ".*?foreignKey": "[a-z\\_]+", + ".*?annotations": ".*" + } } } } \ No newline at end of file diff --git a/Validation/Base/Json.php b/Validation/Base/Json.php index b1ac46492..cafba655b 100644 --- a/Validation/Base/Json.php +++ b/Validation/Base/Json.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace phpOMS\Validation\Base; +use phpOMS\Utils\StringUtils; use phpOMS\Validation\ValidatorAbstract; /** @@ -193,28 +194,26 @@ abstract class Json extends ValidatorAbstract } foreach ($source as $sPath => $sValue) { - $sourceIsValid = false; - $foundPath = false; + $isValidValue = false; + $pathFound = false; foreach ($validPaths as $tPath => $tValue) { - if (!$foundPath - && ($tPath === $sPath - || \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1) + if ($tPath === $sPath + || \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1 ) { - $foundPath = true; - } + $pathFound = true; + $sValue = StringUtils::stringify($sValue); - if (($tPath === $sPath - || \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1) - && ($tValue === $sValue + if (($tValue === $sValue || \preg_match('~' . ((string) $tValue) . '~', (string) $sValue) === 1) - ) { - $sourceIsValid = true; - break; + ) { + $isValidValue = true; + break; + } } } - if (!$sourceIsValid && $foundPath) { + if (!$isValidValue && $pathFound) { return false; } }