diff --git a/kong/db/schema/init.lua b/kong/db/schema/init.lua index cbe6fe0ebf2c..1ac2a773b28c 100644 --- a/kong/db/schema/init.lua +++ b/kong/db/schema/init.lua @@ -734,9 +734,11 @@ function Schema:validate_field(field, value) if field[k] then local ok, err = self.validators[k](value, field[k], field) if not ok then + if not err then + err = (validation_errors[k:upper()] + or validation_errors.VALIDATION):format(value) + end return nil, err - or validation_errors[k:upper()]:format(value) - or validation_errors.VALIDATION:format(value) end end end