Added validation and error formatting as module