Skip to content

Commit 3bac6b2

Browse files
authored
Merge pull request #26 from jsonjoy-com/copilot/fix-25
Refactor `toJtdForm()` methods to use centralized converter with switch statement
2 parents e9b943a + ce7b822 commit 3bac6b2

File tree

21 files changed

+554
-127
lines changed

21 files changed

+554
-127
lines changed

src/__demos__/samples.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export const types = {
8181
'pubsub.channel.Channel': s.Object(
8282
[
8383
s.prop('id', s.str, {title: 'ID of the user'}),
84-
s.prop('payload', s.Ref('pubsub.channel.PayloadType'), {description: 'Yup, the payload.'}),
84+
s.prop('payload', s.Ref('pubsub.channel.PayloadType'), {
85+
description: 'Yup, the payload.',
86+
}),
8587
s.prop('meta', s.Object([s.Field('description', s.str)])),
8688
],
8789
{description: 'A channel'},

src/codegen/binary/__tests__/testBinaryCodegen.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ export const testBinaryCodegen = (transcode: (system: TypeSystem, type: Type, va
409409
const t = system.t;
410410
system.alias('Obj', t.Object(t.prop('foo', t.str)));
411411
const type = t.Ref('Obj');
412-
expect(transcode(system, type, {foo: 'bar'})).toStrictEqual({foo: 'bar'});
412+
expect(transcode(system, type, {foo: 'bar'})).toStrictEqual({
413+
foo: 'bar',
414+
});
413415
});
414416
});
415417

src/codegen/json/__tests__/json.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ describe('"obj" type', () => {
117117
exec(type, {a: 123, b: 'asdf'});
118118
exec(type, {a: 123, b: 'asdf', c: 'qwerty'});
119119
exec(type, {a: 123, d: 4343.3, b: 'asdf', c: 'qwerty', e: 'asdf'});
120-
exec(type, {a: 123, d: 4343.3, b: 'asdf', c: 'qwerty', e: 'asdf', z: true});
120+
exec(type, {
121+
a: 123,
122+
d: 4343.3,
123+
b: 'asdf',
124+
c: 'qwerty',
125+
e: 'asdf',
126+
z: true,
127+
});
121128
});
122129
});
123130

src/codegen/validator/ValidatorCodegenContext.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,14 @@ export class ValidatorCodegenContext {
131131
const v = this.linkValidator(validatorName);
132132
const rerr = codegen.getRegister();
133133
const rc = codegen.getRegister();
134-
const err = this.err(ValidationError.VALIDATION, path, {validator: validatorName, refError: rerr});
135-
const errInCatch = this.err(ValidationError.VALIDATION, path, {validator: validatorName, refError: rc});
134+
const err = this.err(ValidationError.VALIDATION, path, {
135+
validator: validatorName,
136+
refError: rerr,
137+
});
138+
const errInCatch = this.err(ValidationError.VALIDATION, path, {
139+
validator: validatorName,
140+
refError: rc,
141+
});
136142
const emitRc = this.options.errors === 'object';
137143
codegen.js(/* js */ `try {
138144
var ${rerr} = ${v}(${r});

0 commit comments

Comments
 (0)