Conditional validator