mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58: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\\_]+",
|
||||||
".*": {
|
"fields": {
|
||||||
"name": "[a-z]+",
|
".*": {
|
||||||
"type": ".+",
|
"name": "[a-z\\_]+",
|
||||||
".*?default": "1|0",
|
"type": "[A-Z0-9\\(\\)]+",
|
||||||
".*?null": "1|0",
|
".*?default": ".*",
|
||||||
".*?primary": "1|0",
|
".*?null": "1|0",
|
||||||
".*?unique": "1|0",
|
".*?primary": "1|0",
|
||||||
".*?autoincrement": "1|0",
|
".*?unique": "1|0",
|
||||||
".*?foreignTable": "[a-z]+",
|
".*?autoincrement": "1|0",
|
||||||
".*?foreignKey": "[a-z]+"
|
".*?foreignTable": "[a-z\\_]+",
|
||||||
|
".*?foreignKey": "[a-z\\_]+",
|
||||||
|
".*?annotations": ".*"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\Validation\Base;
|
namespace phpOMS\Validation\Base;
|
||||||
|
|
||||||
|
use phpOMS\Utils\StringUtils;
|
||||||
use phpOMS\Validation\ValidatorAbstract;
|
use phpOMS\Validation\ValidatorAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -193,28 +194,26 @@ abstract class Json extends ValidatorAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($source as $sPath => $sValue) {
|
foreach ($source as $sPath => $sValue) {
|
||||||
$sourceIsValid = false;
|
$isValidValue = false;
|
||||||
$foundPath = false;
|
$pathFound = false;
|
||||||
|
|
||||||
foreach ($validPaths as $tPath => $tValue) {
|
foreach ($validPaths as $tPath => $tValue) {
|
||||||
if (!$foundPath
|
if ($tPath === $sPath
|
||||||
&& ($tPath === $sPath
|
|| \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1
|
||||||
|| \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1)
|
|
||||||
) {
|
) {
|
||||||
$foundPath = true;
|
$pathFound = true;
|
||||||
}
|
$sValue = StringUtils::stringify($sValue);
|
||||||
|
|
||||||
if (($tPath === $sPath
|
if (($tValue === $sValue
|
||||||
|| \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1)
|
|
||||||
&& ($tValue === $sValue
|
|
||||||
|| \preg_match('~' . ((string) $tValue) . '~', (string) $sValue) === 1)
|
|| \preg_match('~' . ((string) $tValue) . '~', (string) $sValue) === 1)
|
||||||
) {
|
) {
|
||||||
$sourceIsValid = true;
|
$isValidValue = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sourceIsValid && $foundPath) {
|
if (!$isValidValue && $pathFound) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user