MCPcopy
hub / github.com/encode/django-rest-framework / fail

Method fail

rest_framework/fields.py:590–601  ·  view source on GitHub ↗

A helper method that simply raises a validation error.

(self, key, **kwargs)

Source from the content-addressed store, hash-verified

588 )
589
590 def fail(self, key, **kwargs):
591 """
592 A helper method that simply raises a validation error.
593 """
594 try:
595 msg = self.error_messages[key]
596 except KeyError:
597 class_name = self.__class__.__name__
598 msg = MISSING_ERROR_MESSAGE.format(class_name=class_name, key=key)
599 raise AssertionError(msg)
600 message_string = msg.format(**kwargs)
601 raise ValidationError(message_string, code=key)
602
603 @property
604 def root(self):

Callers 15

validate_empty_valuesMethod · 0.95
to_nativeMethod · 0.80
test_choicesMethod · 0.80
test_single_choicesMethod · 0.80
test_nested_choicesMethod · 0.80
test_mixed_choicesMethod · 0.80
get_querysetMethod · 0.80
_resolve_urlpatternsMethod · 0.80
to_internal_valueMethod · 0.80

Calls 1

ValidationErrorClass · 0.90

Tested by 10

to_nativeMethod · 0.64
test_choicesMethod · 0.64
test_single_choicesMethod · 0.64
test_nested_choicesMethod · 0.64
test_mixed_choicesMethod · 0.64
get_querysetMethod · 0.64
_resolve_urlpatternsMethod · 0.64