diff --git a/app/Rules/FormPropertyLogicRule.php b/app/Rules/FormPropertyLogicRule.php index fae01c0..6e0784d 100644 --- a/app/Rules/FormPropertyLogicRule.php +++ b/app/Rules/FormPropertyLogicRule.php @@ -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; diff --git a/tests/Feature/Forms/FormPropertyLogicTest.php b/tests/Feature/Forms/FormPropertyLogicTest.php index 430aea1..ad3b1d7 100644 --- a/tests/Feature/Forms/FormPropertyLogicTest.php +++ b/tests/Feature/Forms/FormPropertyLogicTest.php @@ -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"); }); \ No newline at end of file