Customer validator

is there any example code to write custom validator?