Fix potential NPE in validator.