avoid using next in validate method

Instead of using next with if condition, used unless condition directly.