﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33591	Incorrect validation message	Maria Sorokina	nobody	"Hello!

**What I did:** I've created a model and added a ''clean'' method to it to validate two fields together. I've created a dictionary of errors, and raised ''ValidationError'' with that dictionary as an argument. I've checked creating new model in standard admin site.

**What I expected to see:** when I have an error I should see a message ""Test1"".

**What I got:** I see error message ""Enter a whole number."".

**What I noticed:** if I remove ''code=""invalid""'' parameter then I get the correct message ""Test1"".

**My code:**

{{{#!python
from django.db import models
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator


class Confidant(models.Model):

    CALENDARS = (
        ('L', 'Lunar'),
        ('G', 'Gregorian'),
        ('J', 'Julian'),
    )
    
    MONTHS = (
        (1, 'January'),
        (2, 'February'),
        (3, 'March'),
        (4, 'April'),
        (5, 'May'),
        (6, 'June'),
        (7, 'July'),
        (8, 'August'),
        (9, 'September'),
        (10, 'October'),
        (11, 'November'),
        (12, 'December'),
    )

    id = models.BigAutoField(primary_key=True)
    height = models.PositiveSmallIntegerField(
        validators=[
            MinValueValidator(130),
            MaxValueValidator(210),
        ],
    )
    birth_month = models.PositiveSmallIntegerField(choices=MONTHS)
    birth_day = models.PositiveSmallIntegerField(
        validators=[
            MinValueValidator(1),
            MaxValueValidator(31),
        ],
    )
    calendar = models.CharField(max_length=1, choices=CALENDARS)

    def clean(self):
        errors = {}
        if (
            self.birth_month == 2 and self.birth_day > 29
            or self.birth_month in [4,6,9,11] and self.birth_day > 30
        ):
            #errors['birth_day'] = ValidationError('Test1') #shows correct message
            errors['birth_day'] = ValidationError('Test1', code='invalid') #shows wrong message
        if errors:
            raise ValidationError(errors)
}}}"	Bug	closed	Forms	4.0	Normal	invalid	ValidationError, validation, message		Unreviewed	0	0	0	0	0	0
