Skip to content

Commit

Permalink
[FIX] Validator contructor checks (#567)
Browse files Browse the repository at this point in the history
Validate schemaName properly based on the enum by fixing a typo in tests & correcting the logical expression
  • Loading branch information
d3xter666 authored Feb 7, 2023
1 parent f981d62 commit 292b454
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/validation/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const SCHEMA_VARIANTS = {

class Validator {
constructor({Ajv, ajvErrors, schemaName}) {
if (!schemaName && !SCHEMA_VARIANTS[schemaName]) {
if (!schemaName || !SCHEMA_VARIANTS[schemaName]) {
throw new Error(
`"schemaName" is missing or incorrect. The available schemaName variants are ${Object.keys(
SCHEMA_VARIANTS
Expand Down
2 changes: 1 addition & 1 deletion test/lib/validation/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test("Validator requires a valid schemaName", (t) => {
const Ajv = sinon.stub();
const ajvErrors = sinon.stub();
const invalidContructor = () => {
new Validator({Ajv, ajvErrors, schemName: "invalid schema name"});
new Validator({Ajv, ajvErrors, schemaName: "invalid schema name"});
};

t.throws(invalidContructor, {
Expand Down

0 comments on commit 292b454

Please sign in to comment.