Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Validation doesn't work when setting ErrorMessage parameter #5

Closed
Edddy opened this Issue · 7 comments

2 participants

@Edddy

If you try to override the default error message the validation is skipped and always validate
i.e:

public class Product {

    [Required]
    public String Name { get; set; }

    // this wont work
    [Required(ErrorMessage = "Other is required")]
    public String Other { get; set; }

}

Results

@jgauffin jgauffin closed this
@Edddy

Was this fixed or it's a "Won't fix"?

@Edddy

@jgauffin: It's hard to be collaborative if you don't communicate with us

@jgauffin
Owner

I'm on vacation. Will look at is as soon as I get back. I thought that I had fixed it. However it's hard to get everything working properly (1. be able to use custom validation attributes 2. use the built in attributes 3. use custom error messages in the attributes).

Microsoft hides the actual language handling inside the dataannotation attributes and then caches them in MVC3.

@Edddy

I understand it's hard and I can try to help you in anything you need, but we need that you coordinate the efforts. Anything from "Too hard, won't fix", "Please try to fix it yourself", or "Fixed" is good for me.

Hope you enjoy your vacations!

@jgauffin
Owner

Should work now

@Edddy

Excellent!

How to we instanciate the providers now? This old sample code does not work now

        var stringProvider = new ResourceStringProvider(Resources.LocalizedStrings.ResourceManager);
        ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(stringProvider);
        ModelValidatorProviders.Providers.Clear();
        ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider(stringProvider));
@jgauffin
Owner

humm. That should work. What kind of error do you get? (although I never tried with a string table only)

(you can email me at jonas.gauffin@gmail.com for faster responses regarding this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.