Fix logic operator issue (#104)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
5df4488c25
commit
825492bf45
|
@ -562,7 +562,7 @@ class FormPropertyLogicRule implements Rule, DataAwareRule
|
|||
|
||||
private function checkConditions($conditions)
|
||||
{
|
||||
if (isset($conditions['operatorIdentifier'])) {
|
||||
if (array_key_exists('operatorIdentifier', $conditions)) {
|
||||
if (($conditions['operatorIdentifier'] !== 'and') && ($conditions['operatorIdentifier'] !== 'or')) {
|
||||
$this->conditionErrors[] = 'missing operator';
|
||||
$this->isConditionCorrect = false;
|
||||
|
|
|
@ -135,4 +135,38 @@ it('can validate form logic rules for conditions', function () {
|
|||
$validatorObj = $this->app['validator']->make($data, $rules);
|
||||
$this->assertFalse($validatorObj->passes());
|
||||
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic conditions for Name are not complete. Error detail(s): missing condition value");
|
||||
|
||||
$data = [
|
||||
'properties' => [
|
||||
[
|
||||
'id' => "title",
|
||||
'name' => "Name",
|
||||
'type' => 'text',
|
||||
'hidden' => false,
|
||||
'required' => false,
|
||||
'logic' => [
|
||||
"conditions" => [
|
||||
"operatorIdentifier"=> null,
|
||||
"children"=> [
|
||||
[
|
||||
"identifier"=> "title",
|
||||
"value"=> [
|
||||
"operator"=> "starts_with",
|
||||
"property_meta"=> [
|
||||
"id"=> "title",
|
||||
"type"=> "text"
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"actions" => []
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$validatorObj = $this->app['validator']->make($data, $rules);
|
||||
$this->assertFalse($validatorObj->passes());
|
||||
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic conditions for Name are not complete. Error detail(s): missing operator");
|
||||
});
|
Loading…
Reference in New Issue