Skip to content

Commit

Permalink
Undeprecate .nonempty()
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Dec 10, 2024
1 parent b333f96 commit 0c6cbbd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as z from "../index.ts";
const minFive = z.string().min(5, "min5");
const maxFive = z.string().max(5, "max5");
const justFive = z.string().length(5);
const nonempty = z.string().min(1, "nonempty");
const nonempty = z.string().nonempty("nonempty");
const includes = z.string().includes("includes");
const includesFromIndex2 = z.string().includes("includes", { position: 2 });
const startsWith = z.string().startsWith("startsWith");
Expand Down
8 changes: 5 additions & 3 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,10 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
}
base64url(message?: errorUtil.ErrMessage) {
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
return this._addCheck({ kind: "base64url", ...errorUtil.errToObj(message) });
return this._addCheck({
kind: "base64url",
...errorUtil.errToObj(message),
});
}

jwt(options?: { alg?: string; message?: string }) {
Expand Down Expand Up @@ -1267,8 +1270,7 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
}

/**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
* Equivalent to `.min(1)`
*/
nonempty(message?: errorUtil.ErrMessage) {
return this.min(1, errorUtil.errToObj(message));
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as z from "../index";
const minFive = z.string().min(5, "min5");
const maxFive = z.string().max(5, "max5");
const justFive = z.string().length(5);
const nonempty = z.string().min(1, "nonempty");
const nonempty = z.string().nonempty("nonempty");
const includes = z.string().includes("includes");
const includesFromIndex2 = z.string().includes("includes", { position: 2 });
const startsWith = z.string().startsWith("startsWith");
Expand Down
8 changes: 5 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,10 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
}
base64url(message?: errorUtil.ErrMessage) {
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
return this._addCheck({ kind: "base64url", ...errorUtil.errToObj(message) });
return this._addCheck({
kind: "base64url",
...errorUtil.errToObj(message),
});
}

jwt(options?: { alg?: string; message?: string }) {
Expand Down Expand Up @@ -1267,8 +1270,7 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
}

/**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
* Equivalent to `.min(1)`
*/
nonempty(message?: errorUtil.ErrMessage) {
return this.min(1, errorUtil.errToObj(message));
Expand Down

0 comments on commit 0c6cbbd

Please sign in to comment.