Added the validate function

@All please review