Skip to content

Commit

Permalink
breaking: [N4S] Remove ensure export as it is now replaced by the laz…
Browse files Browse the repository at this point in the history
…y enforce interface (#497)
  • Loading branch information
ealush authored Nov 13, 2020
1 parent 8e3386b commit bbe0159
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 293 deletions.
9 changes: 0 additions & 9 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,9 @@
"enforceRunner": [
"./packages/n4s/src/enforce/enforceRunner.js"
],
"ensure": [
"./packages/n4s/src/ensure/ensure.js"
],
"ensureRunner": [
"./packages/n4s/src/ensure/ensureRunner.js"
],
"enforceExtended": [
"./packages/n4s/src/extended/enforceExtended.js"
],
"ensureExtended": [
"./packages/n4s/src/extended/ensureExtended.js"
],
"rulesExtended": [
"./packages/n4s/src/extended/rulesExtended.js"
],
Expand Down
15 changes: 12 additions & 3 deletions packages/n4s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ enforce(4)
npm i n4s
```

## Using enforce without a testing framework
## Non throwing validations

If you wish to use enforce's functionality without it throwing errors, you can use its [ensure](https://ealush.github.io/n4s/#/ensure) interface.
> This functionality replaces the no-longer supported ensure export, as it performs the same functionality with better performance.
If you wish to use enforce's functionality safely with a boolean return interface, you can use its lazy validation interface:

```js
enforce
.isArray()
.longerThan(3)
.test([1,2,3])
```

[Read the docs](https://ealush.github.io/n4s)

- [List of enforce rules](https://ealush.github.io/n4s/#/rules)
- [Schema validation](https://ealush.github.io/n4s/#/shape)
- [Custom enforce rules](https://ealush.github.io/n4s/#/custom)
- [Non throwing validations](https://ealush.github.io/n4s/#/ensure)
14 changes: 0 additions & 14 deletions packages/n4s/config/rollup/ensure.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/n4s/config/rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import enforce from './enforce';
import enforceExtended from './enforceExtended';
import ensure from './ensure';

export default [].concat(enforce, ensure, enforceExtended);
export default [].concat(enforce, enforceExtended);
15 changes: 12 additions & 3 deletions packages/n4s/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ enforce(4)
npm i n4s
```

## Using enforce without a testing framework
## Non throwing validations

If you wish to use enforce's functionality without it throwing errors, you can use its [ensure](./ensure) interface.
> This functionality replaces the no-longer supported ensure export, as it performs the same functionality with better performance.
If you wish to use enforce's functionality safely with a boolean return interface instead, you can use its lazy validation interface:

```js
enforce
.isArray()
.longerThan(3)
.test([1,2,3])
```

## Content

- [List of Enforce rules](./rules)
- [Business reated rules](./business_rules)
- [Schema validation](./shape)
- [Custom Enforce Rules](./custom)
- [Non throwing validations (ensure)](./ensure)
1 change: 0 additions & 1 deletion packages/n4s/docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
- [Business reated rules](./business_rules)
- [Schema validations](./shape)
- [Custom Enforce Rules](./custom)
- [Non throwing validations (ensure)](./ensure)
40 changes: 0 additions & 40 deletions packages/n4s/docs/ensure.md

This file was deleted.

10 changes: 0 additions & 10 deletions packages/n4s/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,9 @@
"./enforceExtended.umd.development.js": "./enforceExtended.umd.development.js",
"./enforceExtended.umd.production.js": "./enforceExtended.umd.production.js",
"./enforceExtended.umd.production.min.js": "./enforceExtended.umd.production.min.js",
"./ensure.cjs.development.js": "./ensure.cjs.development.js",
"./ensure.cjs.production.js": "./ensure.cjs.production.js",
"./ensure.cjs.production.min.js": "./ensure.cjs.production.min.js",
"./ensure.js": "./ensure.js",
"./ensure.umd.development.js": "./ensure.umd.development.js",
"./ensure.umd.production.js": "./ensure.umd.production.js",
"./ensure.umd.production.min.js": "./ensure.umd.production.min.js",
"./esm/enforceExtended.mjs.development.js": "./esm/enforceExtended.mjs.development.js",
"./esm/enforceExtended.mjs.production.js": "./esm/enforceExtended.mjs.production.js",
"./esm/enforceExtended.mjs.production.min.js": "./esm/enforceExtended.mjs.production.min.js",
"./esm/ensure.mjs.development.js": "./esm/ensure.mjs.development.js",
"./esm/ensure.mjs.production.js": "./esm/ensure.mjs.production.js",
"./esm/ensure.mjs.production.min.js": "./esm/ensure.mjs.production.min.js",
"./esm/n4s.mjs.development.js": "./esm/n4s.mjs.development.js",
"./esm/n4s.mjs.production.js": "./esm/n4s.mjs.production.js",
"./esm/n4s.mjs.production.min.js": "./esm/n4s.mjs.production.min.js",
Expand Down
85 changes: 0 additions & 85 deletions packages/n4s/src/ensure/__tests__/ensure.test.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/n4s/src/ensure/__tests__/ensureRunner.test.js

This file was deleted.

75 changes: 0 additions & 75 deletions packages/n4s/src/ensure/ensure.js

This file was deleted.

19 changes: 0 additions & 19 deletions packages/n4s/src/ensure/ensureRunner.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/n4s/src/extended/ensureExtended.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/vest/docs/enforce.md
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,9 @@ enforce.extend({

## Shape validations

Enforce (only, not ensure) comes with a built-in lean schema validator rule called `shape`. It allows you to use all the existing and custom rules of enforce to validate the shape of an object.
Enforce comes with a built-in lean schema validator rule called `shape`. It allows you to use all the existing and custom rules of enforce to validate the shape of an object.

When using enforce rules inside your shape, use the rules that exist as properties on enforce itself (`enforce.isString()`). For rules used like this, rule chaining is not possible.
When using enforce rules inside your shape, use the rules that exist as properties on enforce itself (`enforce.isString()`).

### Example

Expand Down
2 changes: 1 addition & 1 deletion packages/vest/src/typings/vest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type LazyInside = (

type TEnforceLazy = {
[key: string]: (...args: any[]) => TEnforceLazy | boolean;
run: (...args: any[]) => boolean;
test: (...args: any[]) => boolean;
equals: LazyAny;
notEquals: LazyAny;
numberEquals: LazyNumeral;
Expand Down

0 comments on commit bbe0159

Please sign in to comment.