Validating query limit with a max value