|
1 | 1 | # Yup
|
2 | 2 |
|
3 |
| -Yup is a JavaScript object schema validator and object parser. The API and style is ~~stolen~~ heavily inspired |
4 |
| -by [Joi](https://github.com/hapijs/joi), which is an amazing library but is generally too large and difficult |
5 |
| -to package for use in a browser. Yup is leaner: in the same spirit, without some of the fancy features. |
6 |
| -You can use it on the server as well, but in that case you might as well just use Joi. |
| 3 | +Yup is a JavaScript schema builder for value parsing and validation. Define a schema, transform a value to match, validate the shape of an existing value, or both. Yup schema are extremely expressive and allow modeling complex, interdependent validations, or value transformations. |
7 | 4 |
|
8 |
| -Yup is also a good bit less opinionated than joi, allowing for custom transformations and async validation. |
9 |
| -It also allows "stacking" conditions via `when` for properties that depend on more than one other sibling or |
10 |
| -child property. Yup separates the parsing and validating functions into separate steps so it can be used to parse |
11 |
| -json separate from validating it, via the `cast` method. |
| 5 | +Yup's API is heavily inspired by [Joi](https://github.com/hapijs/joi), but leaner and built with client-side validation as it's primary use-case. Yup separates the parsing and validating functions into separate steps. `cast()` transforms data while `validate` checks that the input is the correct shape. Each can be preformed together (such as form HTML form validation) or seperately (such as deserializing trusted data from API's). |
12 | 6 |
|
13 | 7 | **Try it out:** https://runkit.com/jquense/yup#
|
14 | 8 |
|
@@ -122,11 +116,7 @@ npm install -D @types/yup
|
122 | 116 |
|
123 | 117 | ## Usage
|
124 | 118 |
|
125 |
| -You define and create schema objects. Schema objects are immutable, so each call of a method returns a _new_ schema object. |
126 |
| - |
127 |
| -**try it out using tonicdev! https://tonicdev.com/570c52590a85f71200eb09ba/yup** |
128 |
| - |
129 |
| -When using es module syntax, yup exports everything as a named export |
| 119 | +You define and create schema objects. Schema objects are immutable, so each call of a method returns a _new_ schema object. When using es module syntax, yup exports everything as a named export |
130 | 120 |
|
131 | 121 | ```js
|
132 | 122 | import * as yup from 'yup'; // for everything
|
|
1 commit comments
john-raymon commentedon Jan 29, 2020
I noticed this change heavily for some reason lol.