Skip to content

Commit

Permalink
Merge pull request #63 from duplojs/fix/62
Browse files Browse the repository at this point in the history
fix(62): protected accelerators to public
  • Loading branch information
mathcovax authored Dec 9, 2024
2 parents 5acaab5 + 5e7b938 commit 3f51cd3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scripts/accelerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare module "zod" {
}

export abstract class ZodAccelerator {
protected static accelerators: ZodAccelerator[] = [];
public static accelerators: ZodAccelerator[] = [];

protected static zod = zod;

Expand Down Expand Up @@ -87,7 +87,7 @@ export abstract class ZodAccelerator {
}

public static autoInstance(zodAccelerator: new(...args: any[]) => ZodAccelerator) {
ZodAccelerator.accelerators.push(new zodAccelerator());
ZodAccelerator.accelerators.unshift(new zodAccelerator());
}

public static injectZod<
Expand Down
1 change: 0 additions & 1 deletion scripts/accelerators/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class ZodTypeAccelerator extends ZodAccelerator {
const $output = ${mayBeAwait} $this.zodSchema.${parseMethod}($input);
if($output.success === false){
$output.error.message = $output.error.message.replace(".", \`$path.\`);
return {
success: false,
error: new ZodAcceleratorError(\`$path\`, "ZodSchema Fail parse.")
Expand Down
6 changes: 3 additions & 3 deletions scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// https://github.dev/colinhacks/zod

// must be import at first
import "./accelerators/type";

import "./accelerators/string";
import "./accelerators/number";
import "./accelerators/object";
Expand Down Expand Up @@ -31,9 +34,6 @@ import "./accelerators/bigInt";
import "./accelerators/effects";
import "./accelerators/lazy";

// must be import at last
import "./accelerators/type";

export * from "./accelerator";
export * from "./error";
export * from "./parser";
Expand Down

0 comments on commit 3f51cd3

Please sign in to comment.