Declarative validation written in javascript