Skip to content

Commit

Permalink
Export jsdoc with @deprecated when building (#2717)
Browse files Browse the repository at this point in the history
* export with comments

* Avoid using arrow function in class

* to jsdoc
  • Loading branch information
amotarao authored Oct 4, 2023
1 parent 15ba5a4 commit 699ccae
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
3 changes: 1 addition & 2 deletions configs/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"outDir": "../lib",
"declaration": true,
"declarationMap": false,
"sourceMap": false,
"removeComments": true
"sourceMap": false
},
"exclude": ["../src/**/__tests__", "../playground.ts"]
}
29 changes: 17 additions & 12 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,16 +849,17 @@ export class ZodString extends ZodType<string, ZodStringDef> {
return { status: status.value, value: input.data };
}

protected _regex = (
protected _regex(
regex: RegExp,
validation: StringValidation,
message?: errorUtil.ErrMessage
) =>
this.refinement((data) => regex.test(data), {
) {
return this.refinement((data) => regex.test(data), {
validation,
code: ZodIssueCode.invalid_string,
...errorUtil.errToObj(message),
});
}

_addCheck(check: ZodStringCheck) {
return new ZodString({
Expand Down Expand Up @@ -980,26 +981,30 @@ export class ZodString extends ZodType<string, ZodStringDef> {
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/
nonempty = (message?: errorUtil.ErrMessage) =>
this.min(1, errorUtil.errToObj(message));
nonempty(message?: errorUtil.ErrMessage) {
return this.min(1, errorUtil.errToObj(message));
}

trim = () =>
new ZodString({
trim() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "trim" }],
});
}

toLowerCase = () =>
new ZodString({
toLowerCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }],
});
}

toUpperCase = () =>
new ZodString({
toUpperCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }],
});
}

get isDatetime() {
return !!this._def.checks.find((ch) => ch.kind === "datetime");
Expand Down Expand Up @@ -4853,7 +4858,7 @@ type CustomParams = CustomErrorParams & { fatal?: boolean };
export const custom = <T>(
check?: (data: unknown) => any,
params: string | CustomParams | ((input: any) => CustomParams) = {},
/*
/**
* @deprecated
*
* Pass `fatal` into the params object instead:
Expand Down
29 changes: 17 additions & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,16 +849,17 @@ export class ZodString extends ZodType<string, ZodStringDef> {
return { status: status.value, value: input.data };
}

protected _regex = (
protected _regex(
regex: RegExp,
validation: StringValidation,
message?: errorUtil.ErrMessage
) =>
this.refinement((data) => regex.test(data), {
) {
return this.refinement((data) => regex.test(data), {
validation,
code: ZodIssueCode.invalid_string,
...errorUtil.errToObj(message),
});
}

_addCheck(check: ZodStringCheck) {
return new ZodString({
Expand Down Expand Up @@ -980,26 +981,30 @@ export class ZodString extends ZodType<string, ZodStringDef> {
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/
nonempty = (message?: errorUtil.ErrMessage) =>
this.min(1, errorUtil.errToObj(message));
nonempty(message?: errorUtil.ErrMessage) {
return this.min(1, errorUtil.errToObj(message));
}

trim = () =>
new ZodString({
trim() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "trim" }],
});
}

toLowerCase = () =>
new ZodString({
toLowerCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }],
});
}

toUpperCase = () =>
new ZodString({
toUpperCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }],
});
}

get isDatetime() {
return !!this._def.checks.find((ch) => ch.kind === "datetime");
Expand Down Expand Up @@ -4853,7 +4858,7 @@ type CustomParams = CustomErrorParams & { fatal?: boolean };
export const custom = <T>(
check?: (data: unknown) => any,
params: string | CustomParams | ((input: any) => CustomParams) = {},
/*
/**
* @deprecated
*
* Pass `fatal` into the params object instead:
Expand Down

0 comments on commit 699ccae

Please sign in to comment.