Skip to content

Commit

Permalink
Removed vriad
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Nov 10, 2020
1 parent e6b11d7 commit f6759d0
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 180 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| [email protected] | Introduced `.safeParse` option.<br>Introduced .regex method on string schemas.<br>Implemented `.primitives()` and `.nonprimitives()` on object schemas.<br>Implemented `z.nativeEnum()` for creating schemas from TypeScript `enum`s.<br>Switched to `new URL()` constructor to check valid URLs. |
| [email protected] | Dropping support for TypeScript 3.2 . |
| [email protected] | Added z.instanceof() and z.custom(). Implemented ZodSchema.array() method. |
| [email protected] | Introduced z.void(). Major overhaul to error handling system, including the introduction of custom error maps. Wrote new [error handling guide](https://github.com/vriad/zod/blob/master/ERROR_HANDLING.md). |
| [email protected] | Introduced z.void(). Major overhaul to error handling system, including the introduction of custom error maps. Wrote new [error handling guide](https://github.com/colinhacks/zod/blob/master/ERROR_HANDLING.md). |
| [email protected] | Added several built-in validators to string, number, and array schemas. Calls to `.refine` now return new instance. |
| [email protected] | Any and unknown types |
| [email protected] | Refinement types (`.refine`), `.parse` no longer returns deep clone |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Before you start working on a contribution, create an issue describing what you
- Create a new branch off the `master` branch: `git checkout -b your-feature-name`
- Implement your contributions (see the Development section for more information)
- Push your branch to the repo: `git push origin your-feature-name`
- Go to https://github.com/vriad/zod/compare and select the branch you just pushed in the "compare:" dropdown
- Go to https://github.com/colinhacks/zod/compare and select the branch you just pushed in the "compare:" dropdown
- Submit the PR. The maintainers will follow up ASAP. -->

## Development
Expand Down
4 changes: 2 additions & 2 deletions ERROR_HANDLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Each ZodError has an `issues` property that is an array of `ZodIssues`. Each iss

`ZodIssue` is _not_ a class. It is a [discriminated union](https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions).

The link above the the best way to learn about the concept. Discriminated unions are an ideal way to represent a data structures that may be one of many possible variants. You can see all the possible variants defined [here](https://github.com/vriad/zod/blob/master/src/ZodError.ts). They are also described in the table below if you prefer.
The link above the the best way to learn about the concept. Discriminated unions are an ideal way to represent a data structures that may be one of many possible variants. You can see all the possible variants defined [here](https://github.com/colinhacks/zod/blob/master/src/ZodError.ts). They are also described in the table below if you prefer.

_Every_ ZodIssue has these fields:

Expand Down Expand Up @@ -142,7 +142,7 @@ As you can see three different issues were identified. Every ZodIssue has a `cod

## Customizing errors with ZodErrorMap

You can customize **all** error messages produced by Zod by providing a custom instance of ZodErrorMap to `.parse()`. Internally, Zod uses a [default error map](https://github.com/vriad/zod/blob/master/defaultErrorMap.ts) to produce all error messages.
You can customize **all** error messages produced by Zod by providing a custom instance of ZodErrorMap to `.parse()`. Internally, Zod uses a [default error map](https://github.com/colinhacks/zod/blob/master/defaultErrorMap.ts) to produce all error messages.

`ZodErrorMap` is a special function. It accepts two arguments: `error` and `ctx`. The return type is `{ message: string }`. Essentially the error map accepts some information about the validation that is failing and returns an appropriate error message.

Expand Down
2 changes: 1 addition & 1 deletion FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: vriad
github: colinhacks
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<h1 align="center">Zod</h1>
</p>
<p align="center">
<a href="https://twitter.com/vriad" rel="nofollow"><img src="https://img.shields.io/badge/created%20by-@vriad-4BBAAB.svg" alt="Created by Colin McDonnell"></a>
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/vriad/zod" alt="License"></a>
<a href="https://twitter.com/colinhacks" rel="nofollow"><img src="https://img.shields.io/badge/created%20by-@colinhacks-4BBAAB.svg" alt="Created by Colin McDonnell"></a>
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/vriad/zod" alt="stars"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
<a href="./src/__tests__" rel="nofollow"><img src="./coverage.svg" alt="coverage"></a>

</p>
Expand All @@ -16,7 +16,7 @@ if you're happy and you know it, star this repo ⭐

<br/>

<!-- **Zod 2 is coming! Follow [@vriad](https://twitter.com/vriad) to stay updated and discuss the future of Zod.** -->
<!-- **Zod 2 is coming! Follow [@colinhacks](https://twitter.com/colinhacks) to stay updated and discuss the future of Zod.** -->

### **Sept 17 — Zod 2 is now in beta!**

Expand Down Expand Up @@ -45,10 +45,10 @@ In almost all cases, you'll be able to upgrade to Zod 2 without changing any cod

Aug 30 — [email protected] was released with lots of cool features!

- All schemas now have a `.safeParse` method. This lets you validate data in a more functional way, similar to `io-ts`: https://github.com/vriad/zod#safe-parse
- String schemas have a new `.regex` refinement method: https://github.com/vriad/zod#strings
- Object schemas now have two new methods: `.primitives()` and `.nonprimitives()`. These methods let you quickly pick or omit primitive fields from objects, useful for validating API inputs: https://github.com/vriad/zod#primitives-and-nonprimitives
- Zod now provides `z.nativeEnum()`, which lets you create z Zod schema from an existing TypeScript `enum`: https://github.com/vriad/zod#native-enums
- All schemas now have a `.safeParse` method. This lets you validate data in a more functional way, similar to `io-ts`: https://github.com/colinhacks/zod#safe-parse
- String schemas have a new `.regex` refinement method: https://github.com/colinhacks/zod#strings
- Object schemas now have two new methods: `.primitives()` and `.nonprimitives()`. These methods let you quickly pick or omit primitive fields from objects, useful for validating API inputs: https://github.com/colinhacks/zod#primitives-and-nonprimitives
- Zod now provides `z.nativeEnum()`, which lets you create z Zod schema from an existing TypeScript `enum`: https://github.com/colinhacks/zod#native-enums

<!-- > ⚠️ You might be encountering issues building your project if you're using zod@<1.10.2. This is the result of a bug in the TypeScript compiler. To solve this without updating, set `"skipLibCheck": true` in your tsconfig.json "compilerOptions". This issue is resolved in [email protected] and later. -->

Expand All @@ -70,7 +70,7 @@ Some other great aspects:

# Sponsorship

I work on Zod in my free time, so if you're making money from a product that is built with Zod, I'd massively appreciate sponsorship at any level. For solo devs, I recommend the [Chipotle Bowl tier](https://github.com/sponsors/vriad) or the [Cup of Coffee tier](https://github.com/sponsors/vriad). If you're making money from a product you built using Zod, consider the [Startup tier]([Cup of Coffee tier](https://github.com/sponsors/vriad)). You can learn more about the tiers at [github.com/sponsors/vriad](github.com/sponsors/vriad).
I work on Zod in my free time, so if you're making money from a product that is built with Zod, I'd massively appreciate sponsorship at any level. For solo devs, I recommend the [Chipotle Bowl tier](https://github.com/sponsors/colinhacks) or the [Cup of Coffee tier](https://github.com/sponsors/colinhacks). If you're making money from a product you built using Zod, consider the [Startup tier]([Cup of Coffee tier](https://github.com/sponsors/colinhacks)). You can learn more about the tiers at [github.com/sponsors/colinhacks](github.com/sponsors/colinhacks).

### Sponsors

Expand Down Expand Up @@ -99,7 +99,7 @@ I work on Zod in my free time, so if you're making money from a product that is
</tr>
</table>

_To get your name + Twitter + website here, sponsor Zod at the [Freelancer](https://github.com/sponsors/vriad) or [Consultancy](https://github.com/sponsors/vriad) tier._
_To get your name + Twitter + website here, sponsor Zod at the [Freelancer](https://github.com/sponsors/colinhacks) or [Consultancy](https://github.com/sponsors/colinhacks) tier._

# Table of contents

Expand Down Expand Up @@ -464,7 +464,7 @@ z.string().url({ message: 'Invalid url' });
z.string().uuid({ message: 'Invalid UUID' });
```

> To see the email and url regexes, check out [this file](https://github.com/vriad/zod/blob/master/src/types/string.ts). To use a more advanced method, use a custom refinement.
> To see the email and url regexes, check out [this file](https://github.com/colinhacks/zod/blob/master/src/types/string.ts). To use a more advanced method, use a custom refinement.
## Numbers

Expand Down Expand Up @@ -1478,7 +1478,6 @@ If this example sounds contrived, check out the homepage of the popular GraphQL
Zod's solution to this is "masking". Masking is known by a lot of other names too: _derived types_, _views_ (especially in the SQL world), _projections_, and more.
#### Picking
```ts
const User = z.object({
Expand Down Expand Up @@ -1638,15 +1637,15 @@ type in = z.input<stringToNumber>; // string

## Errors

There is a dedicated guide on Zod's error handling system here: [ERROR_HANDLING.md](https://github.com/vriad/zod/blob/master/ERROR_HANDLING.md)
There is a dedicated guide on Zod's error handling system here: [ERROR_HANDLING.md](https://github.com/colinhacks/zod/blob/master/ERROR_HANDLING.md)

# Comparison

There are a handful of other widely-used validation libraries, but all of them have certain design limitations that make for a non-ideal developer experience.

<!-- The table below summarizes the feature differences. Below the table there are more involved discussions of certain alternatives, where necessary. -->

<!-- | Feature | [Zod](https://github.com/vriad) | [Joi](https://github.com/hapijs/joi) | [Yup](https://github.com/jquense/yup) | [io-ts](https://github.com/gcanti/io-ts) | [Runtypes](https://github.com/pelotom/runtypes) | [ow](https://github.com/sindresorhus/ow) | [class-validator](https://github.com/typestack/class-validator) |
<!-- | Feature | [Zod](https://github.com/colinhacks) | [Joi](https://github.com/hapijs/joi) | [Yup](https://github.com/jquense/yup) | [io-ts](https://github.com/gcanti/io-ts) | [Runtypes](https://github.com/pelotom/runtypes) | [ow](https://github.com/sindresorhus/ow) | [class-validator](https://github.com/typestack/class-validator) |
| ---------------------------------------------------------------------------------------------------------------------- | :-----------------------------: | :----------------------------------: | :-----------------------------------: | :--------------------------------------: | :---------------------------------------------: | :--------------------------------------: | :-------------------------------------------------------------: |
| <abbr title='Any ability to extract a TypeScript type from a validator instance counts.'>Type inference</abbr> | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| <abbr title="Yup's inferred types are incorrect in certain cases, see discussion below.">Correct type inference</abbr> | 🟢 | 🔴 | 🔴 | 🟢 | 🟢 | 🟢 | 🟢 |
Expand Down Expand Up @@ -1797,4 +1796,4 @@ If you want to validate function inputs, use function schemas in Zod! It's a muc

# Changelog

View the changelog at [CHANGELOG.md](https://github.com/vriad/zod/blob/master/CHANGELOG.md)
View the changelog at [CHANGELOG.md](https://github.com/colinhacks/zod/blob/master/CHANGELOG.md)
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<body>
<nav style="display:flex;flex-direction:row;align-items:center;justify-content:space-between;">
<a href="https://twitter.com/vriad"><span style="color:#888888;">created by @vriad</span></a>
<a href="https://twitter.com/colinhacks"><span style="color:#888888;">created by @colinhacks</span></a>
<a href="#/">Docs</a>
<a href="#/screencasts">Screencasts</a>
</nav>
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
{
"name": "zod",
"version": "2.0.0-beta.18",
"version": "2.0.0-beta.21",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"types": "./lib/cjs/index.d.ts",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "https://github.com/vriad/zod"
"url": "https://github.com/colinhacks/zod"
},
"author": "Colin McDonnell <colin@vriad.com>",
"author": "Colin McDonnell <colin@colinhacks.com>",
"license": "MIT",
"sideEffects": false,
"bugs": {
"url": "https://github.com/vriad/zod/issues"
"url": "https://github.com/colinhacks/zod/issues"
},
"homepage": "https://github.com/vriad/zod",
"homepage": "https://github.com/colinhacks/zod",
"dependencies": {},
"keywords": [
"typescript",
Expand All @@ -29,7 +28,7 @@
],
"scripts": {
"clean": "rm -rf lib/*",
"build": "yarn run clean && tsc --p tsconfig.json && tsc --p tsconfig.esm.json",
"build": "yarn run clean && tsc --p tsconfig.json",
"buildall": "yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add typescript@4 && yarn build && yarn add [email protected]",
"buildallv2": "yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected] && yarn build && yarn add [email protected]",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
Expand All @@ -51,4 +50,4 @@
"tslint-config-prettier": "^1.18.0",
"typescript": "4.0"
}
}
}
2 changes: 1 addition & 1 deletion src/ZodError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZodParsedType } from './parser';
import { util } from './helpers/util';
import { ZodParsedType } from './parser';

export const ZodIssueCode = util.arrayToEnum([
'invalid_type',
Expand Down
Loading

0 comments on commit f6759d0

Please sign in to comment.