[Asp .Net] complex validation logic asking for directions and advice (from BL to Asp .NET MVC GUI)

asp , mvc , validation , forms Ljubljana, Slovenia
  • 11 years ago
    Hello, we have been trying to implement validation logic in our application but it is getting more and more complicated and frustrating so maybe it's time to rethink our methods and implement validation in some other way. Or at least be told from more people that it is the only way to do it and be calmer about it :). I am asking for your advice here. Requirement is to have a single point of configuration, and validation should be applied on multiple levels, on BL (services), GUI (code behind + javascript clientside) all that from a single set of rules. Forms require complex validation rules (custom rules) and multiple combinations of dependent fields (either field 1 and 2 with this and that additional validatotion, or field 1 and 4, or for example if field one is not null, then field 2 is of length 13, otherwise it's of length 10 and so on and so on ....) and we need multiple versions of rulesets (it is quite a huge administration application) For now I have been trying with Enterprise library application validation block. I have written custom validators for objects and rules and I have written a utils class to extract and combine all of the rules from config file and from class attributes into single list of rules to make them available to the GUI layer (Asp MVC) to create automatically javascript validation upon form fields. Now I know that for all those combinations of required fields I could define different rulesets and apply them in order. But in this case error messages can be misleading! For the dependant fields I could write self validation. But this will complicate things too much, we have like 70 forms to implement. And futhermore it gets complicated when automating javascript rule creation .... So, I am asking people with more experience with complex validation, what is best to use, are there any libs worth trying, 3rd party products, whatever? or should I continue struggling with entlib and build my complete validation logic on top of it? If entlib would be you choice then how would you implement required field combinations and validations? Thank you for any ideas and answers PS also I noticed that if rules are defined as attributes inside classess, then only a single instance of a type of validator can be applied to a property (so two validators of the same type but with different parameters can't be applied in attribute notation)

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe