fix: 完善负数校验
This commit is contained in:
parent
0a5cbca4ed
commit
d815d84333
|
@ -680,7 +680,7 @@ class MlogbInSerializer(CustomModelSerializer):
|
||||||
'wm_in': {'required': True, "allow_empty": False}}
|
'wm_in': {'required': True, "allow_empty": False}}
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0 or attrs["count_break"] < 0:
|
if attrs["count_use"] < 0 or attrs.get("count_pn_jgqbl", 0) < 0 or attrs["count_break"] < 0:
|
||||||
raise ParseError('存在负数!')
|
raise ParseError('存在负数!')
|
||||||
mlog:Mlog = attrs['mlog']
|
mlog:Mlog = attrs['mlog']
|
||||||
is_fix = mlog.is_fix
|
is_fix = mlog.is_fix
|
||||||
|
@ -747,7 +747,7 @@ class MlogbInUpdateSerializer(CustomModelSerializer):
|
||||||
fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect']
|
fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect']
|
||||||
|
|
||||||
def validate(self, attrs):
|
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('存在负数!')
|
raise ParseError('存在负数!')
|
||||||
return attrs
|
return attrs
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
|
Loading…
Reference in New Issue