New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

indicative

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indicative - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

19

CHANGELOG.md

@@ -0,1 +1,20 @@

<a name="2.2.0"></a>
# [2.2.0](https://github.com/poppinss/indicative/compare/v2.1.0...v2.2.0) (2016-09-23)
### Bug Fixes
* **rules:equals:** perform loose comparison ([73007b1](https://github.com/poppinss/indicative/commit/73007b1)), closes [#69](https://github.com/poppinss/indicative/issues/69)
* **validator:** fix custom message typo error ([19ec186](https://github.com/poppinss/indicative/commit/19ec186))
* **validator:extend:** make sure to set the extended rule message ([2f1054c](https://github.com/poppinss/indicative/commit/2f1054c))
### Features
* **modes:** add strict mode ([ac07f38](https://github.com/poppinss/indicative/commit/ac07f38)), closes [#72](https://github.com/poppinss/indicative/issues/72)
* **raw:** allow 63 characters long TLD in email ([bd90485](https://github.com/poppinss/indicative/commit/bd90485))
* **rule:** add string validation rule ([b0ee84a](https://github.com/poppinss/indicative/commit/b0ee84a))
<a name="2.1.2"></a>

@@ -2,0 +21,0 @@ ## [2.1.2](https://github.com/poppinss/indicative/compare/v2.1.0...v2.1.2) (2016-06-18)

5

package.json
{
"name": "indicative",
"version": "2.1.2",
"version": "2.2.0",
"description": "Intentionally beautiful schema and raw validator for nodejs",

@@ -31,2 +31,5 @@ "main": "index.js",

},
"standard": {
"global": ["it", "describe", "context", "before", "after", "beforeEach", "afterEach"]
},
"directories": {

@@ -33,0 +36,0 @@ "doc": "docs",

16

readme.md

@@ -308,3 +308,3 @@ # Indicative

const rules = {
'emails': 'array|min:2',
'emails': 'array|min:2',
'emails.*': 'email'

@@ -457,3 +457,3 @@ }

#### toInt
#### toDate
Converts value to date object and returns `null` if unable to convert.

@@ -467,3 +467,3 @@

{
age: 'to_date'
birthday: 'to_date'
}

@@ -1382,2 +1382,3 @@ ```

[starts_with](#starts-with)
[string](#string)
[under](#under)

@@ -1746,2 +1747,11 @@ [url](#url)

#### string
the value of field under validation should be a string
```javascript
{
username: 'string'
}
```
#### under

@@ -1748,0 +1758,0 @@ the value of field should be under defined value

@@ -12,3 +12,3 @@ 'use strict'

const availableModes = ['normal', 'string strict']
const availableModes = ['normal', 'strict']
let currentMode = 'normal'

@@ -15,0 +15,0 @@

@@ -17,4 +17,4 @@ 'use strict'

*/
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)(\+[\w\.-]+)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)(\+[\w\.-]+)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,63}(?:\.[a-z]{2})?)$/i
const phoneRegex = /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/

@@ -21,0 +21,0 @@ const creditCardRegex = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/

@@ -112,13 +112,15 @@ 'use strict'

args.forEach(function (option) {
if (option === '!lc') {
options.lowercase = false
}
if (option === '!rd') {
options.removeDots = false
}
if (option === '!re') {
options.removeExtension = false
}
})
if(args instanceof Array) {
args.forEach(function (option) {
if (option === '!lc') {
options.lowercase = false
}
if (option === '!rd') {
options.removeDots = false
}
if (option === '!re') {
options.removeExtension = false
}
})
}

@@ -125,0 +127,0 @@ if (typeof (value) !== 'string') {

@@ -12,2 +12,3 @@ 'use strict'

const Raw = require('../Raw')
const Modes = require('../Modes')

@@ -31,3 +32,3 @@ /**

const skippable = function (value) {
return !Raw.existy(value) && value !== null
return Modes.get() === 'strict' ? typeof (value) === undefined : !Raw.existy(value)
}

@@ -986,3 +987,3 @@

if (targetedValue === fieldValue) {
if (targetedValue == fieldValue) {
resolve('validation passed')

@@ -1293,4 +1294,31 @@ return

/**
* @description makes sure field under validation is a string
* @method regex
* @param {Object} data
* @param {String} field
* @param {String} message
* @param {Array} args
* @param {Function} get
* @return {Object}
* @public
*/
Validations.string = function (data, field, message, args, get) {
return new Promise(function (resolve, reject) {
const fieldValue = get(data, field)
if (skippable(fieldValue)) {
resolve('validation skipped')
return
}
if (Raw.string(fieldValue)) {
resolve('validation passed')
return
}
reject(message)
})
}
/**
* aliases
*/
Validations.between = Validations.range

@@ -14,3 +14,2 @@ 'use strict'

const Parser = require('../Parser')
const Modes = require('../Modes')
const Messages = require('../Messages')

@@ -59,3 +58,2 @@ const _ = require('lodash')

return Q.Promise((resolve, reject) => {
ValidationEngine.transformValue(data, field)
validationMethod(data, field, message, args, _.get)

@@ -85,22 +83,1 @@ .then(resolve)

}
/**
* transform values of empty string to null when
* string strict mode is on.
*
* @param {Object} data
* @param {String} field
*
* @return {void}
*
* @private
*/
ValidationEngine.transformValue = function (data, field) {
if (Modes.get() !== 'string strict') {
return
}
const value = _.get(data, field)
if (_.isString(value) && _.size(value) === 0) {
_.set(data, field, null)
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc