Added validate api function and test