Simplify code copied from validator.rb

Doesn't really make sense to reuse it, because it is just a couple of
lines now.