Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation naming conventions? C# [closed]

Tags:

c#

standards

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

like image 644
adamwtiko Avatar asked Aug 26 '10 13:08

adamwtiko


1 Answers

It depends what your validation method does.

If it returns a Boolean, then probably starting with Is and ending with Valid is a good place to start. Using is for Boolean calls generally leads to readable code in if statements.

If your validation method throws an exception, then I'd usually start the method name with something like Check instead.

However, also worth considering (as methods should usually use verbs) is beginning the method name with Validate. The Is style is generally more applicable to properties.

like image 160
Alex Humphrey Avatar answered Oct 28 '22 14:10

Alex Humphrey