diff --git a/src/Validator/SmallThanColumn.php b/src/Validator/SmallThanColumn.php index 19f8a29..8874bcf 100644 --- a/src/Validator/SmallThanColumn.php +++ b/src/Validator/SmallThanColumn.php @@ -26,7 +26,7 @@ protected function validate(Param $param, ServerRequestInterface $request): bool throw new Annotation("compare param: {$this->paramName} require in SmallThanColumn rule ,but not define in any controller annotation"); } $compare = $list[$this->paramName]->parsedValue(); - if($itemData > $compare){ + if($itemData >= $compare){ return false; }else{ return true; diff --git a/tests/ControllerExample/Index.php b/tests/ControllerExample/Index.php index 25d04ab..adb1e20 100644 --- a/tests/ControllerExample/Index.php +++ b/tests/ControllerExample/Index.php @@ -9,6 +9,7 @@ use EasySwoole\HttpAnnotation\Document\Document; use EasySwoole\HttpAnnotation\Enum\HttpMethod; use EasySwoole\HttpAnnotation\Enum\ParamFrom; +use EasySwoole\HttpAnnotation\Validator\BigThanColumn; use EasySwoole\HttpAnnotation\Validator\Integer; use EasySwoole\HttpAnnotation\Validator\IsUrl; use EasySwoole\HttpAnnotation\Validator\MaxLength; @@ -19,6 +20,7 @@ use EasySwoole\HttpAnnotation\Validator\OptionalIfParamMiss; use EasySwoole\HttpAnnotation\Validator\OptionalIfParamSet; use EasySwoole\HttpAnnotation\Validator\Required; +use EasySwoole\HttpAnnotation\Validator\SmallThanColumn; class Index extends Base { @@ -169,4 +171,34 @@ function testArray(array $data) { $this->writeJson(Status::CODE_OK,$data); } + + #[Api( + apiName: 'compare', + requestParam: [ + new Param( + name: "a", + validate: [ + new Integer(), + new BigThanColumn('b') + ] + ), + new Param( + name: "b", + validate: [ + new Integer() + ] + ), + new Param( + name: 'c', + validate: [ + new Integer(), + new SmallThanColumn('b') + ] + ) + ] + )] + function compare(array $data) + { + $this->writeJson(Status::CODE_OK,$data); + } } \ No newline at end of file