move the validate query into the @beforeQuery hook