Skip to content

Commit dcfec68

Browse files
authored
Normalize error in validation functions to lowercase (#1064)
1 parent db51f0c commit dcfec68

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

packages/sdk/src/schema/ruleset_validator.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function validateValue(value: any, rule: Rule): ValidationResult {
102102
errors: [
103103
{
104104
path: rule.path,
105-
message: `Expected object at path ${rule.path}`,
105+
message: `expected object at path ${rule.path}`,
106106
},
107107
],
108108
};
@@ -115,7 +115,7 @@ function validateValue(value: any, rule: Rule): ValidationResult {
115115
errors: [
116116
{
117117
path: rule.path,
118-
message: `Expected array at path ${rule.path}`,
118+
message: `expected array at path ${rule.path}`,
119119
},
120120
],
121121
};
@@ -128,7 +128,7 @@ function validateValue(value: any, rule: Rule): ValidationResult {
128128
errors: [
129129
{
130130
path: rule.path,
131-
message: `Expected yorkie.Text at path ${rule.path}`,
131+
message: `expected yorkie.Text at path ${rule.path}`,
132132
},
133133
],
134134
};
@@ -141,7 +141,7 @@ function validateValue(value: any, rule: Rule): ValidationResult {
141141
errors: [
142142
{
143143
path: rule.path,
144-
message: `Expected yorkie.Tree at path ${rule.path}`,
144+
message: `expected yorkie.Tree at path ${rule.path}`,
145145
},
146146
],
147147
};
@@ -154,7 +154,7 @@ function validateValue(value: any, rule: Rule): ValidationResult {
154154
errors: [
155155
{
156156
path: rule.path,
157-
message: `Expected yorkie.Counter at path ${rule.path}`,
157+
message: `expected yorkie.Counter at path ${rule.path}`,
158158
},
159159
],
160160
};
@@ -214,7 +214,7 @@ function validatePrimitiveValue(
214214
errors: [
215215
{
216216
path: rule.path,
217-
message: `Expected ${rule.type} at path ${rule.path}`,
217+
message: `expected ${rule.type} at path ${rule.path}`,
218218
},
219219
],
220220
};

packages/sdk/test/integration/document_schema_test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Document Schema', () => {
8787
syncMode: SyncMode.Manual,
8888
schema: 'noexist@1',
8989
});
90-
assert.fail('Expected an error to be thrown');
90+
assert.fail('expected an error to be thrown');
9191
} catch (error) {
9292
assert.include((error as Error).message, 'schema not found');
9393
}
@@ -119,7 +119,7 @@ describe('Document Schema', () => {
119119
});
120120
},
121121
YorkieError,
122-
`schema validation failed: Expected string at path $.title`,
122+
`schema validation failed: expected string at path $.title`,
123123
);
124124
assert.equal('{}', doc.toSortedJSON());
125125

@@ -251,11 +251,11 @@ describe('Document Schema', () => {
251251
headers: { Authorization: adminToken },
252252
},
253253
);
254-
assert.fail('Expected an error to be thrown');
254+
assert.fail('expected an error to be thrown');
255255
} catch (error) {
256256
assert.equal(
257257
(error as AxiosError<{ message: string }>).response?.data?.message,
258-
'schema validation failed: Expected integer at path $.title',
258+
'schema validation failed: expected integer at path $.title',
259259
);
260260
}
261261

@@ -383,7 +383,7 @@ describe('Document Schema', () => {
383383
} catch (error) {
384384
assert.equal(
385385
(error as AxiosError<{ message: string }>).response?.data?.message,
386-
'schema validation failed: Expected integer at path $.title',
386+
'schema validation failed: expected integer at path $.title',
387387
);
388388
}
389389

@@ -413,7 +413,7 @@ describe('Document Schema', () => {
413413
});
414414
},
415415
YorkieError,
416-
`schema validation failed: Expected string at path $.title`,
416+
`schema validation failed: expected string at path $.title`,
417417
);
418418

419419
await client.deactivate();
@@ -458,7 +458,7 @@ describe('Document Schema', () => {
458458
} catch (error) {
459459
assert.equal(
460460
(error as AxiosError<{ message: string }>).response?.data?.message,
461-
'schema validation failed: Expected integer at path $.title',
461+
'schema validation failed: expected integer at path $.title',
462462
);
463463
}
464464

@@ -546,7 +546,7 @@ describe('Document Schema', () => {
546546
} catch (error) {
547547
assert.equal(
548548
(error as AxiosError<{ message: string }>).response?.data?.message,
549-
'schema validation failed: Expected string at path $.title',
549+
'schema validation failed: expected string at path $.title',
550550
);
551551
}
552552

@@ -576,7 +576,7 @@ describe('Document Schema', () => {
576576
});
577577
},
578578
YorkieError,
579-
`schema validation failed: Expected string at path $.title`,
579+
`schema validation failed: expected string at path $.title`,
580580
);
581581

582582
await client.deactivate();

packages/sdk/test/unit/schema/ruleset_validator_test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,35 @@ describe('ruleset-validator', () => {
7878
expect(result.errors).to.deep.eq([
7979
{
8080
path: '$.field1',
81-
message: 'Expected null at path $.field1',
81+
message: 'expected null at path $.field1',
8282
},
8383
{
8484
path: '$.field2',
85-
message: 'Expected boolean at path $.field2',
85+
message: 'expected boolean at path $.field2',
8686
},
8787
{
8888
path: '$.field3',
89-
message: 'Expected integer at path $.field3',
89+
message: 'expected integer at path $.field3',
9090
},
9191
{
9292
path: '$.field4',
93-
message: 'Expected double at path $.field4',
93+
message: 'expected double at path $.field4',
9494
},
9595
{
9696
path: '$.field5',
97-
message: 'Expected long at path $.field5',
97+
message: 'expected long at path $.field5',
9898
},
9999
{
100100
path: '$.field6',
101-
message: 'Expected string at path $.field6',
101+
message: 'expected string at path $.field6',
102102
},
103103
{
104104
path: '$.field7',
105-
message: 'Expected date at path $.field7',
105+
message: 'expected date at path $.field7',
106106
},
107107
{
108108
path: '$.field8',
109-
message: 'Expected bytes at path $.field8',
109+
message: 'expected bytes at path $.field8',
110110
},
111111
]);
112112
});
@@ -132,7 +132,7 @@ describe('ruleset-validator', () => {
132132
expect(result.errors).to.deep.eq([
133133
{
134134
path: '$.user',
135-
message: 'Expected object at path $.user',
135+
message: 'expected object at path $.user',
136136
},
137137
]);
138138
});
@@ -156,7 +156,7 @@ describe('ruleset-validator', () => {
156156
expect(result.errors).to.deep.eq([
157157
{
158158
path: '$.items',
159-
message: 'Expected array at path $.items',
159+
message: 'expected array at path $.items',
160160
},
161161
]);
162162
});
@@ -185,7 +185,7 @@ describe('ruleset-validator', () => {
185185
expect(result.errors).to.deep.eq([
186186
{
187187
path: '$.user.name',
188-
message: 'Expected string at path $.user.name',
188+
message: 'expected string at path $.user.name',
189189
},
190190
]);
191191
});
@@ -281,15 +281,15 @@ describe('ruleset-validator', () => {
281281
expect(result.errors).to.deep.eq([
282282
{
283283
path: '$.text',
284-
message: 'Expected yorkie.Text at path $.text',
284+
message: 'expected yorkie.Text at path $.text',
285285
},
286286
{
287287
path: '$.tree',
288-
message: 'Expected yorkie.Tree at path $.tree',
288+
message: 'expected yorkie.Tree at path $.tree',
289289
},
290290
{
291291
path: '$.counter',
292-
message: 'Expected yorkie.Counter at path $.counter',
292+
message: 'expected yorkie.Counter at path $.counter',
293293
},
294294
]);
295295
});

0 commit comments

Comments
 (0)