from django.core.exceptions import ValidationError

class EmptyCheck(object):
    def __call__(self, value):
        if len(value.strip()) == 0:
            raise ValidationError("Value cannot be empty")

from django.core.exceptions import ValidationError

# Usage example in a custom form
# firstname = forms.CharField(validators = [EmptyCheck()])
class EmptyCheck(object):
    def __call__(self, value):
        if len(value.strip()) == 0:
            raise ValidationError("Value cannot be empty")

Add comment to show usage example
Add comment to show usage example
  from django.core.exceptions import ValidationError
  
+ # Usage example in a custom form
+ # firstname = forms.CharField(validators = [EmptyCheck()])
  class EmptyCheck(object):
      def __call__(self, value):
          if len(value.strip()) == 0:
              raise ValidationError("Value cannot be empty")
  
Add comment to show usage example
## Code Before:
from django.core.exceptions import ValidationError

class EmptyCheck(object):
    def __call__(self, value):
        if len(value.strip()) == 0:
            raise ValidationError("Value cannot be empty")

## Instruction:
Add comment to show usage example
## Code After:
from django.core.exceptions import ValidationError

# Usage example in a custom form
# firstname = forms.CharField(validators = [EmptyCheck()])
class EmptyCheck(object):
    def __call__(self, value):
        if len(value.strip()) == 0:
            raise ValidationError("Value cannot be empty")
