Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: non-empty validation error message #116

Merged
merged 2 commits into from Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ValidationError.js
Expand Up @@ -1030,7 +1030,7 @@ class ValidationError extends Error {
const { limit } = /** @type {import("ajv").LimitParams} */ (params);

if (limit === 1) {
return `${dataPath} should be an non-empty string${getSchemaNonTypes(
return `${dataPath} should be a non-empty string${getSchemaNonTypes(
parentSchema
)}.${this.getSchemaPartDescription(parentSchema)}`;
}
Expand All @@ -1048,7 +1048,7 @@ class ValidationError extends Error {
const { limit } = /** @type {import("ajv").LimitParams} */ (params);

if (limit === 1) {
return `${dataPath} should be an non-empty array${getSchemaNonTypes(
return `${dataPath} should be a non-empty array${getSchemaNonTypes(
parentSchema
)}.${this.getSchemaPartDescription(parentSchema)}`;
}
Expand All @@ -1062,7 +1062,7 @@ class ValidationError extends Error {
const { limit } = /** @type {import("ajv").LimitParams} */ (params);

if (limit === 1) {
return `${dataPath} should be an non-empty object${getSchemaNonTypes(
return `${dataPath} should be a non-empty object${getSchemaNonTypes(
parentSchema
)}.${this.getSchemaPartDescription(parentSchema)}`;
}
Expand Down
26 changes: 13 additions & 13 deletions test/__snapshots__/index.test.js.snap
Expand Up @@ -425,7 +425,7 @@ exports[`Validation should fail validation for array with maxItems 1`] = `

exports[`Validation should fail validation for array with minItems 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.arrayWithMinItems should be an non-empty array."
- configuration.arrayWithMinItems should be a non-empty array."
`;

exports[`Validation should fail validation for array with only number 1`] = `
Expand Down Expand Up @@ -480,13 +480,13 @@ exports[`Validation should fail validation for boolean type 1`] = `

exports[`Validation should fail validation for configuration dataPath #1 1`] = `
"Invalid options object. MyPlugin has been initialized using an options object that does not match the API schema.
- options.entry should be an non-empty string.
- options.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

exports[`Validation should fail validation for configuration dataPath 1`] = `
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty string.
- configuration.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

Expand Down Expand Up @@ -556,7 +556,7 @@ exports[`Validation should fail validation for contains inside items 1`] = `

exports[`Validation should fail validation for css-loader name 1`] = `
"Invalid configuration object. CSS Loader has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty string.
- configuration.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

Expand Down Expand Up @@ -589,13 +589,13 @@ exports[`Validation should fail validation for empty const 1`] = `

exports[`Validation should fail validation for empty entry bundle array 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.entry['bundle'] should be an non-empty array.
- configuration.entry['bundle'] should be a non-empty array.
-> A non-empty array of non-empty strings"
`;

exports[`Validation should fail validation for empty entry string 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty string.
- configuration.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

Expand Down Expand Up @@ -997,7 +997,7 @@ exports[`Validation should fail validation for min length 1`] = `

exports[`Validation should fail validation for min properties 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty object.
- configuration.entry should be a non-empty object.
-> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array."
`;

Expand Down Expand Up @@ -1152,7 +1152,7 @@ exports[`Validation should fail validation for no type like array with minItems

exports[`Validation should fail validation for no type like array with minItems 3`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.noTypeMinProperties1 should be an non-empty object | should be any non-object."
- configuration.noTypeMinProperties1 should be a non-empty object | should be any non-object."
`;

exports[`Validation should fail validation for no type like array with minItems 4`] = `
Expand All @@ -1162,7 +1162,7 @@ exports[`Validation should fail validation for no type like array with minItems

exports[`Validation should fail validation for no type like array with minItems equals 1 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.noTypeLikeArrayMinItems1 should be an non-empty array | should be any non-array."
- configuration.noTypeLikeArrayMinItems1 should be a non-empty array | should be any non-array."
`;

exports[`Validation should fail validation for no type like number with exclusive maximum 1`] = `
Expand Down Expand Up @@ -1248,7 +1248,7 @@ exports[`Validation should fail validation for no type like string with minLengt

exports[`Validation should fail validation for no type like string with minLength equals 1 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.noTypeLikeStringMinLength1 should be an non-empty string | should be any non-string."
- configuration.noTypeLikeStringMinLength1 should be a non-empty string | should be any non-string."
`;

exports[`Validation should fail validation for no type like string with pattern 1`] = `
Expand Down Expand Up @@ -1302,7 +1302,7 @@ exports[`Validation should fail validation for not empty string #1 1`] = `

exports[`Validation should fail validation for not empty string #2 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.notEmptyString2 should be an non-empty string."
- configuration.notEmptyString2 should be a non-empty string."
`;

exports[`Validation should fail validation for not enum 1`] = `
Expand Down Expand Up @@ -1809,7 +1809,7 @@ exports[`Validation should fail validation for string with minLength, maxLength

exports[`Validation should fail validation for terser-webpack-plugin name 1`] = `
"Invalid configuration object. Terser Plugin has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty string.
- configuration.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

Expand Down Expand Up @@ -1837,7 +1837,7 @@ exports[`Validation should fail validation for uniqueItems 2`] = `

exports[`Validation should fail validation for webpack name 1`] = `
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be an non-empty string.
- configuration.entry should be a non-empty string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup."
`;

Expand Down