For the project I am searching for best validation framework. I have already test validation on IDataErrorInfo method but I am not satisfied cause you need to hardcode property name and you also have to write bunch of code for every property you want to validate.

     public string this[string columnName]
            string error = null;
                switch (columnName)
                    case "Country":
                        if (string.IsNullOrEmpty(this.Posta))
                            error = "Country is reuqired fiel";

Better framework for me is to use Data Annotiations like here(http://www.codeproject.com/Articles/185943/Validation-in-NET-Framework) but this also doesn't fullfil my requirements.

My requirements are:

  • Not to hardcode every property name I would like to validate
  • Validation doesn't occur first time when user enters to form. I would like to validate form when user change some property.
  • To be able to clear all messages. Let's say that my forms has data manipulation mode and search mode. Whem user changes some data, validation works. But when he click Search option, form goes into search mode which means that all erros are cleared. In search mode also validation on input fields are disabled so the user can type what ever search createria.
  • To be able to know in ViewModel if form has all property valid. It would be also cool to be able to know how many properties are valid and how many are not.
  • To be able to have a list of failures for particular field

Does anybody know some kind of a framework to be able to do this? Which one would you recommend?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.