Skip to content

NullReferenceException in ValidationAttribute. #39

Description

@MikhailPikhota

How i may a valigate attribute?
Some changes to your example and have a NullReferenceException in non-default language:

[Localized]
public class LogOnModel
{
    [Required]
    [ValidateUserNameUnique]
    [Display(Name = "User name")]
    public string UserName { get; set; }
...
}
public class ValidateUserNameUnique : ValidationAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var userName = value as string;
        return ValidationResult.Success;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions