indicative
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -0,1 +1,11 @@ | ||
<a name="2.2.1"></a> | ||
## [2.2.1](https://github.com/poppinss/indicative/compare/v2.2.0...v2.2.1) (2016-10-11) | ||
### Bug Fixes | ||
* **validator:** convert message field to snake_case ([cae5884](https://github.com/poppinss/indicative/commit/cae5884)), closes [#76](https://github.com/poppinss/indicative/issues/76) | ||
<a name="2.2.0"></a> | ||
@@ -2,0 +12,0 @@ # [2.2.0](https://github.com/poppinss/indicative/compare/v2.1.0...v2.2.0) (2016-09-23) |
{ | ||
"name": "indicative", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Intentionally beautiful schema and raw validator for nodejs", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "istanbul cover _mocha --report lcovonly -- -R spec test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"coverage": "istanbul cover _mocha test --bail", | ||
"standard": "standard src/**/*.js" | ||
"test": "npm run lint && istanbul cover _mocha --report lcovonly -- -R spec test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"coverage": "npm run lint && istanbul cover _mocha test --bail", | ||
"lint": "standard" | ||
}, | ||
@@ -20,5 +20,5 @@ "author": "amanvirk", | ||
"istanbul": "^0.4.3", | ||
"mocha": "^2.4.5", | ||
"mocha": "^3.0.2", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"standard": "^7.1.0" | ||
"standard": "^8.4.0" | ||
}, | ||
@@ -25,0 +25,0 @@ "dependencies": { |
@@ -12,3 +12,2 @@ 'use strict' | ||
const snakeCaseRegex = /_(\w)/g | ||
const arrayExpressionRegex = /(\w[^\.\*]+)(\.\*\.?)(.+)?/ | ||
@@ -66,15 +65,2 @@ const _ = require('lodash') | ||
/** | ||
* convert a snake case string to camelcase. | ||
* | ||
* @param {String} string | ||
* | ||
* @return {String} | ||
*/ | ||
Parser.toCamelCase = function (string) { | ||
return string.replace(snakeCaseRegex, function (m, $1) { | ||
return $1.toUpperCase() | ||
}) | ||
} | ||
/** | ||
* parses an array expression to a consumable object | ||
@@ -95,3 +81,2 @@ * | ||
/** | ||
@@ -98,0 +83,0 @@ * parses a rule and returns an object with |
@@ -92,3 +92,3 @@ 'use strict' | ||
.replace(/\//g, '/') | ||
.replace(/\`/g, '`') | ||
.replace(/\//g, '`') | ||
) | ||
@@ -113,3 +113,3 @@ } | ||
if(args instanceof Array) { | ||
if (args instanceof Array) { | ||
args.forEach(function (option) { | ||
@@ -116,0 +116,0 @@ if (option === '!lc') { |
@@ -30,3 +30,3 @@ 'use strict' | ||
function _getSanitizationMethod (filter) { | ||
return _.get(filters, Parser.toCamelCase(filter), function () { | ||
return _.get(filters, _.camelCase(filter), function () { | ||
throw new Error(`${filter} is not defined as a filter`) | ||
@@ -33,0 +33,0 @@ }) |
@@ -985,3 +985,3 @@ 'use strict' | ||
if (targetedValue == fieldValue) { | ||
if (targetedValue == fieldValue) { // eslint-disable-line eqeqeq | ||
resolve('validation passed') | ||
@@ -988,0 +988,0 @@ return |
@@ -13,3 +13,2 @@ 'use strict' | ||
const Validations = require('../Validations') | ||
const Parser = require('../Parser') | ||
const Messages = require('../Messages') | ||
@@ -78,5 +77,5 @@ const _ = require('lodash') | ||
ValidationEngine.getValidationMethod = function (validation) { | ||
return _.get(Validations, Parser.toCamelCase(validation), function () { | ||
return _.get(Validations, _.camelCase(validation), function () { | ||
throw new Error(`${validation} is not defined as a validation`) | ||
}) | ||
} |
@@ -125,3 +125,3 @@ 'use strict' | ||
Validations[name] = method | ||
Messages.set(name, message) | ||
Messages.set(_.snakeCase(name), message) | ||
} | ||
@@ -128,0 +128,0 @@ |
110802
2859