Skip to content

Commit

Permalink
Merge pull request #212 from shimataro/develop
Browse files Browse the repository at this point in the history
version 0.15.1
  • Loading branch information
shimataro authored Aug 19, 2018
2 parents b1292ed + 19cd435 commit f4d4b96
Show file tree
Hide file tree
Showing 46 changed files with 666 additions and 695 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.15.1] - 2018-08-19
### Others
* enhance `index.d.ts` for [TypeScript](https://www.typescriptlang.org/) products

## [0.15.0] - 2018-08-18
### Added
* `adjuster.boolean()`
Expand Down Expand Up @@ -174,7 +178,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.1.0] - 2018-04-18
* First release.

[Unreleased]: https://github.com/shimataro/node-adjuster/compare/v0.15.0...HEAD
[Unreleased]: https://github.com/shimataro/node-adjuster/compare/v0.15.1...HEAD
[0.15.1]: https://github.com/shimataro/node-adjuster/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/shimataro/node-adjuster/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/shimataro/node-adjuster/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/shimataro/node-adjuster/compare/v0.12.0...v0.13.0
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ validate and adjust input values
## Introduction

All of web applications need handling input parameters, consists of following steps:
* fill default values
* cast types
* validate values
* ...and revise them if needed
1. existence check
* all required parameters exist?
* fill omittable parameters by default values
1. type check
* e.g., `typeof age === "number`
* cast them if needed; `"20"`(string) to `20`(number)
1. domain check
* e.g., `1 <= limit & limit <= 100`
* revise them if needed; `0` to `1`

`node-adjuster` does all of them, by compact and highly readable code!

Expand Down Expand Up @@ -218,7 +223,7 @@ For more information, see [string](#string).

```typescript
namespace adjuster {
export declare function adjust(data: Object, constraints: Object, onError?: (err: AdjusterError|null) => any): Object;
export declare function adjust(data: any, constraints: Object, onError?: (err: AdjusterError|null) => any): Object;
}
```

Expand Down
51 changes: 31 additions & 20 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adjuster",
"description": "validate and adjust input values",
"version": "0.15.0",
"version": "0.15.1",
"author": "shimataro",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -45,6 +45,7 @@
"check-updates": "ncu"
},
"devDependencies": {
"@types/jest": "23.3.1",
"babel-eslint": "8.2.6",
"eslint": "5.4.0",
"eslint-plugin-import": "2.14.0",
Expand Down
73 changes: 0 additions & 73 deletions src/adjusters/array.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,77 +29,4 @@ export default () =>
@Default
class ArrayAdjuster extends AdjusterBase
{
/**
* set default value; enable to omit
* @method
* @name ArrayAdjuster#default
* @param {Array} value default value
* @returns {ArrayAdjuster}
*/

/**
* accept null
* @method
* @name ArrayAdjuster#acceptNull
* @param {?Array} [value=null] value on null
* @returns {ArrayAdjuster}
*/

/**
* accept empty string
* @method
* @name ArrayAdjuster#acceptEmptyString
* @param {?Array} [value=null] value on empty
* @returns {ArrayAdjuster}
*/

/**
* accept string and set separator
* @method
* @name ArrayAdjuster#separatedBy
* @param {string|RegExp} separator separator
* @returns {ArrayAdjuster}
*/

/**
* convert to array, if not
* @method
* @name ArrayAdjuster#toArray
* @returns {ArrayAdjuster}
*/

/**
* set min-length of array elements
* @method
* @name ArrayAdjuster#minLength
* @param {number} length min-length; error if shorter
* @returns {ArrayAdjuster}
*/

/**
* set max-length of array elements
* @method
* @name ArrayAdjuster#maxLength
* @param {number} length max-length
* @param {boolean} [adjust=false] truncate if longer; default is ERROR
* @returns {ArrayAdjuster}
*/

/**
* apply constraints for each elements
* @method
* @name ArrayAdjuster#each
* @param {AdjusterBase} adjusterInstance adjuster to apply
* @param {boolean} [ignoreEachErrors=false] ignore errors of each elements
* @returns {ArrayAdjuster}
*/

/**
* do adjust
* @method
* @name ArrayAdjuster#adjust
* @param {*} value value to be checked
* @param {?AdjusterBase.OnError} [onError=null] callback function on error
* @returns {Array} adjusted value
*/
}
47 changes: 0 additions & 47 deletions src/adjusters/boolean.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,4 @@ export default () =>
@Default
class BooleanAdjuster extends AdjusterBase
{
/**
* enable strict type check
* @method
* @name BooleanAdjuster#strict
* @returns {BooleanAdjuster}
*/

/**
* accept all numbers as boolean
* @method
* @name BooleanAdjuster#acceptAllNumbers
* @returns {BooleanAdjuster}
*/

/**
* set default value
* @method
* @name BooleanAdjuster#default
* @param {boolean} value default value
* @returns {BooleanAdjuster}
*/

/**
* accept null
* @method
* @name BooleanAdjuster#acceptNull
* @param {?boolean} [value=null] value on null
* @returns {BooleanAdjuster}
*/

/**
* accept empty string
* @method
* @name BooleanAdjuster#acceptEmptyString
* @param {?boolean} [value=null] value on empty
* @returns {BooleanAdjuster}
*/

/**
* do adjust
* @method
* @name BooleanAdjuster#adjust
* @param {*} value value to be checked
* @param {?AdjusterBase.OnError} [onError=null] callback function on error
* @returns {boolean} adjusted value
* @throws {AdjusterError}
*/
}
49 changes: 0 additions & 49 deletions src/adjusters/email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,53 +65,4 @@ class EmailAdjuster extends AdjusterBase

this.pattern(REGEXP);
}

/**
* set default value
* @method
* @name EmailAdjuster#default
* @param {string} value default value
* @returns {EmailAdjuster}
*/

/**
* accept null
* @method
* @name EmailAdjuster#acceptNull
* @param {?string} [value=null] value on null
* @returns {EmailAdjuster}
*/

/**
* remove whitespace from both ends
* @method
* @name EmailAdjuster#trim
* @returns {EmailAdjuster}
*/

/**
* accept empty string
* @method
* @name EmailAdjuster#acceptEmptyString
* @param {?string} [value=null] value on empty
* @returns {EmailAdjuster}
*/

/**
* specify acceptable pattern by regular expression
* @method
* @name EmailAdjuster#pattern
* @param {string|RegExp} pattern acceptable pattern(regular expression); string or RegExp
* @returns {EmailAdjuster}
*/

/**
* do adjust
* @method
* @name EmailAdjuster#adjust
* @param {*} value value to be checked
* @param {?AdjusterBase.OnError} [onError=null] callback function on error
* @returns {string} adjusted value
* @throws {AdjusterError}
*/
}
Loading

0 comments on commit f4d4b96

Please sign in to comment.