validate date function