MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / validate

Method validate

mongoengine/fields.py:483–496  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

481 return float(self.to_python(value))
482
483 def validate(self, value):
484 if not isinstance(value, decimal.Decimal):
485 if not isinstance(value, str):
486 value = str(value)
487 try:
488 value = decimal.Decimal(value)
489 except (TypeError, ValueError, decimal.InvalidOperation) as exc:
490 self.error("Could not convert value to decimal: %s" % exc)
491
492 if self.min_value is not None and value < self.min_value:
493 self.error("Decimal value is too small")
494
495 if self.max_value is not None and value > self.max_value:
496 self.error("Decimal value is too large")
497
498 def prepare_query_value(self, op, value):
499 if value is None:

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected