fix: event validator
This commit is contained in:
parent
2cc2a40377
commit
95317d87b8
|
@ -87,11 +87,14 @@ class Event extends Validator
|
|||
}
|
||||
|
||||
if ($attribute ?? false) {
|
||||
if (
|
||||
!\array_key_exists($attribute, $events[$type][$action]) ||
|
||||
(($subType ?? false) && !\array_key_exists($attribute, $events[$type][$subType][$action]))
|
||||
) {
|
||||
return false;
|
||||
if (($subType ?? false)) {
|
||||
if (!\array_key_exists($attribute, $events[$type][$subType][$action])) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!\array_key_exists($attribute, $events[$type][$action])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ class EventValidatorTest extends TestCase
|
|||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*.memberships.*.update.status'));
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
@ -57,5 +58,6 @@ class EventValidatorTest extends TestCase
|
|||
$this->assertFalse($this->object->isValid('collections.*.documents.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
||||
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue