Lightweight ChainValidator class for Django validators
📍Ever had a model field fail three different validation checks at once, flooding your user or API response with multiple error messages?
💧 By default, Django runs every validator in a validators list and returns all triggered ValidationError exceptions together. But in many cases, you want to short-circuit the validation - stop at the very first error so the user only sees one fixable issue at a time.
Here is a lightweight ChainValidator class that does exactly that!
It runs your validators sequentially, stops immediately at the first failure, and includes a deconstruct() method so Django can seamlessly serialize it into database migration files.
✅ Usage:
name = models.CharField(max_length=100,validators=[ChainValidator([validate_first_name, ua_name_validator])])
