This commit is contained in:
2024-01-10 17:35:55 +08:00
parent 1066aa03e8
commit 88fb563c99
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -476,7 +476,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
public function save(): static|bool
{
if (!$this->validator($this->rules()) || !$this->beforeSave($this)) {
if (!$this->validator($this->rules(), $this->_attributes) || !$this->beforeSave($this)) {
return FALSE;
}
if (!$this->isNewExample) {
@@ -537,13 +537,13 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
* @return bool
* @throws
*/
public function validator(array $rule): bool
public function validator(array $rule, array $params): bool
{
if (count($rule) < 1 || $this->skipValidate) {
return TRUE;
}
$validate = $this->resolve($rule);
if (!$validate->validation($this)) {
if (!$validate->validation($params)) {
return \Kiri::getLogger()->failure($validate->getError() . PHP_EOL, 'mysql');
} else {
return TRUE;