Is something wrong with validating string or the exception is not thrown?