Very simple question, but I want to start using a consistent naming convention for validation methods and I can’t think of the best way!
Do people tend to use IsDataValid() style? or are there any others that are more descriptive and meaningful?
Cheers
It depends what your validation method does.
If it returns a Boolean, then probably starting with
Isand ending withValidis a good place to start. Usingisfor Boolean calls generally leads to readable code inifstatements.If your validation method throws an exception, then I’d usually start the method name with something like
Checkinstead.However, also worth considering (as methods should usually use verbs) is beginning the method name with
Validate. TheIsstyle is generally more applicable to properties.