Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Dec 12, 2022
1 parent b9db3e7 commit 6e6efc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
21 changes: 13 additions & 8 deletions deno/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ const myFunction = z
.function()
.args(z.string(), z.number()) // accepts an arbitrary number of arguments
.returns(z.boolean());

type myFunction = z.infer<typeof myFunction>;
// => (arg0: string, arg1: number)=>boolean
```
Expand Down Expand Up @@ -1595,8 +1596,9 @@ const myFunction = z
.function()
.args(z.string())
.implement((arg) => {
return [arg.length]; //
return [arg.length];
});

myFunction; // (arg: string)=>number[]
```

Expand Down Expand Up @@ -1659,6 +1661,7 @@ Given any Zod schema, you can call its `.parse` method to check `data` is valid.
```ts
const stringSchema = z.string();

stringSchema.parse("fish"); // => returns "fish"
stringSchema.parse(12); // throws Error('Non-string type: number');
```
Expand Down Expand Up @@ -1762,7 +1765,7 @@ type RefineParams = {
For advanced cases, the second argument can also be a function that returns `RefineParams`/

```ts
z.string().refine(
const longString = z.string().refine(
(val) => val.length > 10,
(val) => ({ message: `${val} is not more than 10 characters` })
);
Expand All @@ -1779,8 +1782,9 @@ const passwordForm = z
.refine((data) => data.password === data.confirm, {
message: "Passwords don't match",
path: ["confirm"], // path of error
})
.parse({ password: "asdf", confirm: "qwer" });
});

passwordForm.parse({ password: "asdf", confirm: "qwer" });
```

Because you provided a `path` parameter, the resulting error will be:
Expand Down Expand Up @@ -1929,6 +1933,7 @@ To transform data after parsing, use the `transform` method.

```ts
const stringToNumber = z.string().transform((val) => val.length);

stringToNumber.parse("string"); // => 6
```

Expand Down Expand Up @@ -1975,7 +1980,7 @@ const Strings = z.string().transform((val, ctx) => {
Transforms and refinements can be interleaved. These will be executed in the order they are declared.

```ts
z.string()
const nameToGreeting = z.string()
.transform((val) => val.toUpperCase())
.refine((val) => val.length > 15)
.transform((val) => `Hello ${val}`)
Expand Down Expand Up @@ -2086,7 +2091,7 @@ z.string().optional().nullable();
A convenience method that returns an array schema for the given type:

```ts
const nullableString = z.string().array(); // string[]
const stringArray = z.string().array(); // string[]

// equivalent to
z.array(z.string());
Expand All @@ -2108,7 +2113,7 @@ z.promise(z.string());
A convenience method for union types.

```ts
z.string().or(z.number()); // string | number
const stringOrNumber = z.string().or(z.number()); // string | number

// equivalent to
z.union([z.string(), z.number()]);
Expand All @@ -2119,7 +2124,7 @@ z.union([z.string(), z.number()]);
A convenience method for creating intersection types.

```ts
z.object({ name: z.string() }).and(z.object({ age: z.number() })); // { name: string } & { age: number }
const nameAndAge = z.object({ name: z.string() }).and(z.object({ age: z.number() })); // { name: string } & { age: number }

// equivalent to
z.intersection(z.object({ name: z.string() }), z.object({ age: z.number() }));
Expand Down
2 changes: 1 addition & 1 deletion deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test("more email validations", () => {
`"🍺🕺🎉"@domain.com`,
`poop@💩.la`,
`"🌮"@i❤️tacos.ws`,
"sss--asd@i❤️tacos.ws"
"sss--asd@i❤️tacos.ws",
];
const email = z.string().email();
for (const datum of data) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zod",
"version": "3.20",
"version": "3.20.0",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"main": "./lib/index.js",
"types": "./index.d.ts",
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 @@ -49,7 +49,7 @@ test("more email validations", () => {
`"🍺🕺🎉"@domain.com`,
`poop@💩.la`,
`"🌮"@i❤️tacos.ws`,
"sss--asd@i❤️tacos.ws"
"sss--asd@i❤️tacos.ws",
];
const email = z.string().email();
for (const datum of data) {
Expand Down

0 comments on commit 6e6efc2

Please sign in to comment.