mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
Fix json template validation bugs
This commit is contained in:
parent
e60952e75b
commit
6e2bfebc60
|
|
@ -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": ".*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user