diff --git a/src/factories/transform.ts b/src/factories/transform.ts index 5096f30..bf227f8 100644 --- a/src/factories/transform.ts +++ b/src/factories/transform.ts @@ -140,7 +140,8 @@ export const either = * }; * * @typeParam T - The validated type - * @param first - The validator + * @param first - The validator */ -export const optional = (validator: Validator): Validator => - either(validator, isUndefined); +export const optional = ( + validator: Validator, +): Validator => either(validator, isUndefined); diff --git a/src/factories/validate.spec.ts b/src/factories/validate.spec.ts index c66591c..13f04db 100644 --- a/src/factories/validate.spec.ts +++ b/src/factories/validate.spec.ts @@ -75,7 +75,10 @@ describe("validateWith", () => { expect(validator({ a: "1" }).parsed).toEqual({ a: "1", b: undefined }); expect(validator({ a: "1", b: undefined }).valid).toBe(true); - expect(validator({ a: "1", b: undefined }).parsed).toEqual({ a: "1", b: undefined }); + expect(validator({ a: "1", b: undefined }).parsed).toEqual({ + a: "1", + b: undefined, + }); expect(validator({ a: "1", b: 1 }).error).toEqual({ b: "Not a string: 1" }); expect(validator({ a: "1", b: "1" }).parsed).toEqual({ a: "1", b: 1 }); @@ -144,7 +147,10 @@ describe("validateWithAtLeast", () => { expect(validator({ a: "1" }).parsed).toEqual({ a: "1", b: undefined }); expect(validator({ a: "1", b: undefined }).valid).toBe(true); - expect(validator({ a: "1", b: undefined }).parsed).toEqual({ a: "1", b: undefined }); + expect(validator({ a: "1", b: undefined }).parsed).toEqual({ + a: "1", + b: undefined, + }); expect(validator({ a: "1", b: 1 }).error).toEqual({ b: "Not a string: 1" }); expect(validator({ a: "1", b: "1" }).parsed).toEqual({ a: "1", b: 1 });