fix: update CRUD验证跳过前端未传的字段,不做合法性检查

This commit is contained in:
Hermes Agent 2026-06-24 18:01:31 +08:00
parent a55654674a
commit 7b8010cf9f

View File

@ -374,12 +374,12 @@ _validation_rules = json.loads(r'''{{validation_rules}}''')
import re as _re
_errors = []
for _fname, _rules in _validation_rules.items():
\t_val = params_kw.get(_fname, '')
\tif _val is None: _val = ''
\t_val = str(_val)
\t# Update: skip validation if field is empty (not modified)
\tif not _val or _val.strip() == '':
\tif _fname not in params_kw:
\t\tcontinue
\t_val = params_kw.get(_fname)
\tif _val is None or str(_val).strip() == '':
\t\tcontinue
\t_val = str(_val)
\tfor _rule in _rules:
\t\t_rt = _rule.get('type', '')
\t\t_rm = _rule.get('message', _fname)