Skip to content

Commit

Permalink
Ref: naming: proprietaryKind -> kind.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Jan 10, 2024
1 parent a6a2ffc commit 50eb27d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface Metadata<T extends z.ZodTypeAny> {
* @todo if the following PR merged, use native branding instead:
* @link https://github.com/colinhacks/zod/pull/2860
* */
proprietaryKind?: ProprietaryKind;
kind?: ProprietaryKind;
examples: z.input<T>[];
}

Expand Down Expand Up @@ -77,9 +77,9 @@ export const proprietary = <T extends z.ZodTypeAny>(
subject: T,
) => {
const schema = withMeta(subject);
schema._def[metaProp].proprietaryKind = kind;
schema._def[metaProp].kind = kind;
return schema;
};

export const isProprietary = (schema: z.ZodTypeAny, kind: ProprietaryKind) =>
getMeta(schema, "proprietaryKind") === kind;
getMeta(schema, "kind") === kind;
2 changes: 1 addition & 1 deletion src/schema-walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const walkSchema = <U, Context extends FlatObject = {}>({
rules: HandlingRules<U, Context>;
onMissing: SchemaHandler<z.ZodTypeAny, U, Context, "last">;
}): U => {
const kind = getMeta(schema, "proprietaryKind") || schema._def.typeName;
const kind = getMeta(schema, "kind") || schema._def.typeName;
const handler = kind ? rules[kind as keyof typeof rules] : undefined;
const ctx = rest as unknown as Context;
const next: SchemaHandler<z.ZodTypeAny, U, {}, "last"> = (params) =>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/date-in-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("ez.dateIn()", () => {
test("should create an instance", () => {
const schema = ez.dateIn();
expect(schema).toBeInstanceOf(z.ZodPipeline);
expect(getMeta(schema, "proprietaryKind")).toEqual("DateIn");
expect(getMeta(schema, "kind")).toEqual("DateIn");
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/date-out-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("ez.dateOut()", () => {
test("should create an instance", () => {
const schema = ez.dateOut();
expect(schema).toBeInstanceOf(z.ZodEffects);
expect(getMeta(schema, "proprietaryKind")).toEqual("DateOut");
expect(getMeta(schema, "kind")).toEqual("DateOut");
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/file-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("ez.file()", () => {
test("should create an instance being string by default", () => {
const schema = ez.file();
expect(schema).toBeInstanceOf(z.ZodString);
expect(getMeta(schema, "proprietaryKind")).toBe("File");
expect(getMeta(schema, "kind")).toBe("File");
});

test.each([ez.file("string"), ez.file().string()])(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/upload-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("ez.upload()", () => {
test("should create an instance", () => {
const schema = ez.upload();
expect(schema).toBeInstanceOf(z.ZodEffects);
expect(getMeta(schema, "proprietaryKind")).toBe("Upload");
expect(getMeta(schema, "kind")).toBe("Upload");
});
});

Expand Down

0 comments on commit 50eb27d

Please sign in to comment.