Skip to content

Commit 8727bd3

Browse files
committed
Use lowercase for all errors
1 parent 80536fa commit 8727bd3

File tree

5 files changed

+75
-75
lines changed

5 files changed

+75
-75
lines changed

src/compileValueSchema.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function compileAnyOfSchema(compiler: Compiler, schema: OpenAPIAnyOfSchema) {
9393
);
9494
});
9595

96-
nodes.push(builders.returnStatement(error('Expected one of the anyOf schemas to match')));
96+
nodes.push(builders.returnStatement(error('expected one of the anyOf schemas to match')));
9797

9898
return nodes;
9999
});
@@ -147,7 +147,7 @@ function compileOneOfSchema(compiler: Compiler, schema: OpenAPIOneOfSchema) {
147147
),
148148
builders.blockStatement([
149149
builders.returnStatement(
150-
error('Expected to only match one of the schemas'),
150+
error('expected to only match one of the schemas'),
151151
),
152152
]),
153153
),
@@ -224,7 +224,7 @@ function compileObjectSchema(compiler: Compiler, schema: OpenAPIObjectSchema) {
224224
),
225225
builders.binaryExpression('===', value, builders.literal(null)),
226226
),
227-
builders.blockStatement([builders.returnStatement(error('Expected an object'))]),
227+
builders.blockStatement([builders.returnStatement(error('expected an object'))]),
228228
),
229229
);
230230

@@ -259,7 +259,7 @@ function compileObjectSchema(compiler: Compiler, schema: OpenAPIObjectSchema) {
259259
),
260260
builders.blockStatement([
261261
builders.returnStatement(
262-
error(`Expected at least ${schema.minProperties} properties`),
262+
error(`expected at least ${schema.minProperties} properties`),
263263
),
264264
]),
265265
),
@@ -276,7 +276,7 @@ function compileObjectSchema(compiler: Compiler, schema: OpenAPIObjectSchema) {
276276
),
277277
builders.blockStatement([
278278
builders.returnStatement(
279-
error(`Expected at most ${schema.maxProperties} properties`),
279+
error(`expected at most ${schema.maxProperties} properties`),
280280
),
281281
]),
282282
),
@@ -354,7 +354,7 @@ function compileObjectSchema(compiler: Compiler, schema: OpenAPIObjectSchema) {
354354
builders.blockStatement(check),
355355
schema.required?.includes(key)
356356
? builders.blockStatement([
357-
builders.returnStatement(error(`Expected "${key}" to be defined`)),
357+
builders.returnStatement(error(`expected "${key}" to be defined`)),
358358
])
359359
: subSchema.default !== undefined
360360
? builders.blockStatement([
@@ -381,7 +381,7 @@ function compileObjectSchema(compiler: Compiler, schema: OpenAPIObjectSchema) {
381381
builders.literal(0),
382382
),
383383
builders.blockStatement([
384-
builders.returnStatement(error(`Unexpected properties`)),
384+
builders.returnStatement(error(`unexpected properties`)),
385385
]),
386386
),
387387
);
@@ -465,7 +465,7 @@ function compileArraySchema(compiler: Compiler, schema: OpenAPIArraySchema) {
465465
[value],
466466
),
467467
),
468-
builders.blockStatement([builders.returnStatement(error('Expected an array'))]),
468+
builders.blockStatement([builders.returnStatement(error('expected an array'))]),
469469
),
470470
);
471471

@@ -479,7 +479,7 @@ function compileArraySchema(compiler: Compiler, schema: OpenAPIArraySchema) {
479479
),
480480
builders.blockStatement([
481481
builders.returnStatement(
482-
error(`Expected at least ${schema.minItems} items`),
482+
error(`expected at least ${schema.minItems} items`),
483483
),
484484
]),
485485
),
@@ -496,7 +496,7 @@ function compileArraySchema(compiler: Compiler, schema: OpenAPIArraySchema) {
496496
),
497497
builders.blockStatement([
498498
builders.returnStatement(
499-
error(`Expected at most ${schema.maxItems} items`),
499+
error(`expected at most ${schema.maxItems} items`),
500500
),
501501
]),
502502
),
@@ -553,7 +553,7 @@ function compileArraySchema(compiler: Compiler, schema: OpenAPIArraySchema) {
553553
[itemResult],
554554
),
555555
builders.blockStatement([
556-
builders.returnStatement(error(`Expected unique items`)),
556+
builders.returnStatement(error(`expected unique items`)),
557557
]),
558558
),
559559
builders.expressionStatement(
@@ -611,7 +611,7 @@ function compileNumberSchema(
611611
builders.unaryExpression('typeof', value),
612612
builders.literal('number'),
613613
),
614-
builders.blockStatement([builders.returnStatement(error('Expected a number'))]),
614+
builders.blockStatement([builders.returnStatement(error('expected a number'))]),
615615
),
616616
);
617617

@@ -637,7 +637,7 @@ function compileStringSchema(compiler: Compiler, schema: OpenAPIStringSchema) {
637637
builders.unaryExpression('typeof', value),
638638
builders.literal('string'),
639639
),
640-
builders.blockStatement([builders.returnStatement(error('Expected a string'))]),
640+
builders.blockStatement([builders.returnStatement(error('expected a string'))]),
641641
),
642642
);
643643

@@ -689,7 +689,7 @@ function compileStringSchema(compiler: Compiler, schema: OpenAPIStringSchema) {
689689
),
690690
builders.blockStatement([
691691
builders.returnStatement(
692-
error(`Expected at least ${schema.minLength} characters`),
692+
error(`expected at least ${schema.minLength} characters`),
693693
),
694694
]),
695695
),
@@ -706,7 +706,7 @@ function compileStringSchema(compiler: Compiler, schema: OpenAPIStringSchema) {
706706
),
707707
builders.blockStatement([
708708
builders.returnStatement(
709-
error(`Expected at most ${schema.maxLength} characters`),
709+
error(`expected at most ${schema.maxLength} characters`),
710710
),
711711
]),
712712
),
@@ -737,7 +737,7 @@ function compileStringSchema(compiler: Compiler, schema: OpenAPIStringSchema) {
737737
),
738738
builders.blockStatement([
739739
builders.returnStatement(
740-
error(`Expected to match the pattern "${schema.pattern}"`),
740+
error(`expected to match the pattern "${schema.pattern}"`),
741741
),
742742
]),
743743
),
@@ -766,7 +766,7 @@ function compileBooleanSchema(compiler: Compiler, schema: OpenAPIBooleanSchema)
766766
builders.unaryExpression('typeof', value),
767767
builders.literal('boolean'),
768768
),
769-
builders.blockStatement([builders.returnStatement(error('Expected a boolean'))]),
769+
builders.blockStatement([builders.returnStatement(error('expected a boolean'))]),
770770
),
771771
);
772772

@@ -824,7 +824,7 @@ function compileEnumableCheck(
824824
null as namedTypes.BinaryExpression | namedTypes.LogicalExpression | null,
825825
)!,
826826
builders.blockStatement([
827-
builders.returnStatement(error('Expected one of the enum value')),
827+
builders.returnStatement(error('expected one of the enum value')),
828828
]),
829829
),
830830
builders.returnStatement(value),

src/tests/__snapshots__/compileOperation.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class ValidationError extends Error {
3030
}
3131
function obj2(path, value, context) {
3232
if (typeof value !== 'number') {
33-
return new ValidationError(path, 'Expected a number');
33+
return new ValidationError(path, 'expected a number');
3434
}
3535
return value;
3636
}
3737
function obj1(path, value, context) {
3838
if (typeof value !== 'object' || value === null) {
39-
return new ValidationError(path, 'Expected an object');
39+
return new ValidationError(path, 'expected an object');
4040
}
4141
const keys = new Set(Object.keys(value));
4242
const value0 = value['foo'];
@@ -52,7 +52,7 @@ function obj1(path, value, context) {
5252
keys.delete('foo');
5353
}
5454
if (keys.size > 0) {
55-
return new ValidationError(path, 'Unexpected properties');
55+
return new ValidationError(path, 'unexpected properties');
5656
}
5757
return value;
5858
}

src/tests/__snapshots__/compilePath.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ function obj1(path, value, context) {
1818
}
1919
function obj4(path, value, context) {
2020
if (typeof value !== 'number') {
21-
return new ValidationError(path, 'Expected a number');
21+
return new ValidationError(path, 'expected a number');
2222
}
2323
return value;
2424
}
2525
function obj3(path, value, context) {
2626
if (typeof value !== 'object' || value === null) {
27-
return new ValidationError(path, 'Expected an object');
27+
return new ValidationError(path, 'expected an object');
2828
}
2929
const keys = new Set(Object.keys(value));
3030
const value0 = value['foo'];
@@ -40,7 +40,7 @@ function obj3(path, value, context) {
4040
keys.delete('foo');
4141
}
4242
if (keys.size > 0) {
43-
return new ValidationError(path, 'Unexpected properties');
43+
return new ValidationError(path, 'unexpected properties');
4444
}
4545
return value;
4646
}

0 commit comments

Comments
 (0)