fix: 完善负数校验

This commit is contained in:
caoqianming 2025-04-24 16:00:09 +08:00
parent 9df6294617
commit ca7d56a462
1 changed files with 2 additions and 2 deletions

View File

@ -691,7 +691,7 @@ class MlogbInSerializer(CustomModelSerializer):
'wm_in': {'required': True, "allow_empty": False}}
def validate(self, attrs):
if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0 or attrs.get("count_break", 0) < 0:
if attrs["count_use"] < 0 or attrs.get("count_pn_jgqbl", 0) < 0 or attrs["count_break"] < 0:
raise ParseError('存在负数!')
mlog:Mlog = attrs['mlog']
is_fix = mlog.is_fix
@ -753,7 +753,7 @@ class MlogbInUpdateSerializer(CustomModelSerializer):
fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect', "need_inout"]
def validate(self, attrs):
if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0:
if attrs["count_use"] < 0 or attrs.get("count_pn_jgqbl", 0) < 0:
raise ParseError('存在负数!')
return attrs
def update(self, instance, validated_data):