This project is read-only.

ValidationGroup in client

Mar 13, 2009 at 10:52 AM

I have a question:

How can I group validations with metadata in properties?

I mean, Is it posible that the framework creates validation groups in the client side?
I am thinking in something like this in the server side

    [Required] [Group("Client")]
    public string ClientName { get; set; }
    [Range(1, 20)] [Group("Guests")]
    public int NumberOfGuests { get; set; }

to achive two different validation groups in client side.

I guess that it's a N-layer rule violation because it's makes more sense in the UI layer instead of in the application business, but I think it could be usefull

Mar 13, 2009 at 1:14 PM
Following on from another disussion topic I think this is something that we need to put to Steve to include in the xVal source.
I was working on this type of attribute code last night.

Thanks, Mark
Mar 14, 2009 at 12:02 AM
Hey folks

I'm keen to work something out to support this scenario. I'm not sure whether it's really something that should go into xVal (because as you say it's purely a UI feature, so that information doesn't really belong in the model), but I think it will be possible to suggest a way of structuring your UI code to make this work. One of the examples in my forthcoming book is a wizard in which each step is validated separately but all the rules are held centrally in the model.

For the next week I won't be able to do much as I'll be off site, but will get back to this then.

Mar 14, 2009 at 12:23 AM
Actually one possible way you can deal with this is similar to the code sample I just posted at the end of

What do you think of this? No doubt it could be made tidier, but the principle is simple.