n4s 4.0.1 → 4.1.1-dev-0bdac6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md DELETED
@@ -1,44 +0,0 @@
1
- # Enforce - n4s
2
-
3
- Enforce is a validations assertions library. It provides rules that you can test your data against.
4
-
5
- By default, enforce throws an error when your validations fail. These errors should be caught by a validation testing framework such as [Vest](https://github.com/ealush/vest).
6
-
7
- You can extend Enforce per need, and you can add your custom validation rules in your app.
8
-
9
- ```js
10
- import { enforce } from 'n4s';
11
-
12
- enforce(4).isNumber();
13
- // passes
14
-
15
- enforce(4).isNumber().greaterThan(2);
16
- // passes
17
-
18
- enforce(4)
19
- .lessThan(2) // throws an error, will not carry on to the next rule
20
- .greaterThan(3);
21
- ```
22
-
23
- ## Installation
24
-
25
- ```
26
- npm i n4s
27
- ```
28
-
29
- ## Non throwing validations
30
-
31
- > This functionality replaces the no-longer supported ensure export, as it performs the same functionality with better performance.
32
-
33
- If you wish to use enforce's functionality safely with a boolean return interface instead, you can use its lazy validation interface:
34
-
35
- ```js
36
- enforce.isArray().longerThan(3).test([1, 2, 3]);
37
- ```
38
-
39
- ## Content
40
-
41
- - [List of Enforce rules](./rules)
42
- - [Business reated rules](./business_rules)
43
- - [Schema validation](./shape)
44
- - [Custom Enforce Rules](./custom)
package/docs/_sidebar.md DELETED
@@ -1,5 +0,0 @@
1
- - [Main](./)
2
- - [List of Enforce Rules](./rules)
3
- - [Schema validations](./compound)
4
- - [Custom Enforce Rules](./custom)
5
- - [Consuming external rules](./external)
package/docs/external.md DELETED
@@ -1,27 +0,0 @@
1
- # Consuming external rules
2
-
3
- Enforce comes with the bare minimum of rules needed for input validation, not assuming your business logic constraints.
4
-
5
- In some cases you might require more validations such as `isEmail` or `isPhoneNumber`. Enforce intentionally does not include those, since those validations may not necessarily reflect the way those validations should work in your app.
6
-
7
- Luckily, there are numerous packages that can be used along with enforce to add those validations. One of the most popular, and most compatible is `validator.js`.
8
-
9
- ```
10
- npm i validator
11
- ```
12
-
13
- Validator.js is a pretty big package. To prevent it from unnecessarily increasing your bundle size for rules you don't use, import the ones you use individually.
14
-
15
- Then add those rules with `enforce.extend`:
16
-
17
- ```js
18
- import isEmail from 'validator/es/lib/isEmail';
19
- import isMobilePhone from 'validator/es/lib/isMobilePhone';
20
-
21
- enforce.extend({ isEmail, isMobilePhone });
22
-
23
- enforce('example@example.com').isEmail(); // ✅
24
- enforce('example[at]example[dot]com').isEmail(); // 🚨
25
- ```
26
-
27
- A full list of the supported validator.js rules can be found on [npmjs.com/package/validator](https://www.npmjs.com/package/validator).
package/docs/index.html DELETED
@@ -1,32 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <title>n4s - Enforce - Validation assertions library</title>
6
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7
- <meta
8
- name="description"
9
- content="Enforce - Validation assertions library"
10
- />
11
- <meta
12
- name="viewport"
13
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
14
- />
15
- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" />
16
- </head>
17
- <body>
18
- <div id="app"></div>
19
- <script>
20
- window.$docsify = {
21
- name: 'n4s - enforce',
22
- repo: 'https://github.com/ealush/n4s',
23
- search: 'auto',
24
- loadSidebar: true,
25
- subMaxLevel: 2,
26
- themeColor: '#539BDB',
27
- };
28
- </script>
29
- <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
30
- <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
31
- </body>
32
- </html>