Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COso you suggest making a custom one of these for every custom validation scenario you encounter? Sounds like a whole lot of little class files around that are very tightly coupled to your model (might have to change both when you make a change) but it does a nice job of encapsulation for unit testing. Interesting
      singulars
    2. CO@JohnCulviner Well that depends on the developer really. Personally I like to have my controllers lean so if (ModelState.IsValid) { do this } else { do that } - this link elaborates further: http://codebetter.com/iancooper/2008/12/03/the-fat-controller/ I typically don't use data annotations on my model properties, instead I do ALL of my model validation in the Validate override of IValidatableObject. I feel it gives me far more flexibility over validating, and I find it easier to read. But as I say, this is my preference - I've worked with developers who hate models and love controllers.
      singulars
    3. CO@JohnCulviner oh, just to clarify having re-read your comment. I wouldn't have this validation code in a separate file, it would be contained within the model class itself as an overridden method. So each model object in your project would have its own, self-contained validation logic which would be included in the ModelState.IsValid check in your controller. You'd just perform checks in the order you need to, and yield return the results. This would appear as a list of issues to your user on the page.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload