modifs.mineures sans commentaires
This commit is contained in:
parent
94790bef34
commit
0d91228f55
|
@ -51,7 +51,12 @@ class ScalarResult extends Result {
|
|||
$this->result[$name] = $value;
|
||||
}
|
||||
|
||||
function setMissing(ScalarSchema $schema, ?string $key=null): int {
|
||||
protected static function replace_key(string &$message, ?string $key): void {
|
||||
if ($key) $message = str_replace("{key}", $key, $message);
|
||||
else $message = str_replace("{key}: ", "", $message);
|
||||
}
|
||||
|
||||
function setMissing(ScalarSchema $schema): int {
|
||||
$this->missing = true;
|
||||
if (!$schema->required) {
|
||||
$this->null = true;
|
||||
|
@ -60,13 +65,13 @@ class ScalarResult extends Result {
|
|||
return ref_analyze::NORMALIZED;
|
||||
} else {
|
||||
$message = cl::get($schema->messages, "missing");
|
||||
$message = str_replace("{key}", $key, $message);
|
||||
self::replace_key($message, $schema->name);
|
||||
$this->message = $message;
|
||||
return ref_analyze::MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
function setNull(ScalarSchema $schema, ?string $key=null): int {
|
||||
function setNull(ScalarSchema $schema): int {
|
||||
$this->missing = true;
|
||||
if ($schema->nullable) {
|
||||
$this->valid = true;
|
||||
|
@ -74,7 +79,7 @@ class ScalarResult extends Result {
|
|||
return ref_analyze::NORMALIZED;
|
||||
} else {
|
||||
$message = cl::get($schema->messages, "null");
|
||||
$message = str_replace("{key}", $key, $message);
|
||||
self::replace_key($message, $schema->name);
|
||||
$this->message = $message;
|
||||
return ref_analyze::NULL;
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ class ScalarValue extends Value {
|
|||
$destKey = $this->destKey;
|
||||
$result = $this->result;
|
||||
$result->reset();
|
||||
if (!$input->available()) return $result->setMissing($schema, $destKey);
|
||||
$value = $input->get($destKey);
|
||||
if ($value === null) return $result->setNull($schema, $destKey);
|
||||
#XXX résoudre le type
|
||||
if (!$input->available()) return $result->setMissing($schema);
|
||||
$value = $input->get($destKey);
|
||||
if ($value === null) return $result->setNull($schema);
|
||||
}
|
||||
|
||||
function exists(): bool {
|
||||
|
|
Loading…
Reference in New Issue