diff --git a/index.js b/index.js index 6d5cb55..733ad48 100644 --- a/index.js +++ b/index.js @@ -316,11 +316,11 @@ function checkInt(rule, value) { } if (rule.hasOwnProperty('max') && value > rule.max) { - return this.t('should smaller than %s', rule.max); + return this.t('should not bigger than %s', rule.max); } if (rule.hasOwnProperty('min') && value < rule.min) { - return this.t('should bigger than %s', rule.min); + return this.t('should not smaller than %s', rule.min); } } @@ -342,10 +342,10 @@ function checkNumber(rule, value) { return this.t('should be a number'); } if (rule.hasOwnProperty('max') && value > rule.max) { - return this.t('should smaller than %s', rule.max); + return this.t('should not bigger than %s', rule.max); } if (rule.hasOwnProperty('min') && value < rule.min) { - return this.t('should bigger than %s', rule.min); + return this.t('should not smaller than %s', rule.min); } } @@ -385,10 +385,10 @@ function checkString(rule, value) { } if (rule.hasOwnProperty('max') && value.length > rule.max) { - return this.t('length should smaller than %s', rule.max); + return this.t('length should not bigger than %s', rule.max); } if (rule.hasOwnProperty('min') && value.length < rule.min) { - return this.t('length should bigger than %s', rule.min); + return this.t('length should not smaller than %s', rule.min); } if (rule.format && !rule.format.test(value)) { @@ -582,10 +582,10 @@ function checkArray(rule, value) { } if (rule.hasOwnProperty('max') && value.length > rule.max) { - return this.t('length should smaller than %s', rule.max); + return this.t('length should not bigger than %s', rule.max); } if (rule.hasOwnProperty('min') && value.length < rule.min) { - return this.t('length should bigger than %s', rule.min); + return this.t('length should not smaller than %s', rule.min); } if (!rule.itemType) { diff --git a/test/index.test.js b/test/index.test.js index 1a39b48..23e5b06 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -116,13 +116,13 @@ describe('parameter', () => { it('should check max error', () => { var value = { int: 101 }; var rule = { int: {type: 'int', max: 100, min: 1 }}; - parameter.validate(rule, value)[0].message.should.equal('should smaller than 100'); + parameter.validate(rule, value)[0].message.should.equal('should not bigger than 100'); }); it('should check min error', () => { var value = { int: -1 }; var rule = { int: {type: 'int', max: 100, min: 0 }}; - parameter.validate(rule, value)[0].message.should.equal('should bigger than 0'); + parameter.validate(rule, value)[0].message.should.equal('should not smaller than 0'); }); }); @@ -149,13 +149,13 @@ describe('parameter', () => { it('should check max error', () => { var value = { number: 101 }; var rule = { number: {type: 'number', max: 100, min: 1 }}; - parameter.validate(rule, value)[0].message.should.equal('should smaller than 100'); + parameter.validate(rule, value)[0].message.should.equal('should not bigger than 100'); }); it('should check min error', () => { var value = { number: -1 }; var rule = { number: {type: 'number', max: 100, min: 0 }}; - parameter.validate(rule, value)[0].message.should.equal('should bigger than 0'); + parameter.validate(rule, value)[0].message.should.equal('should not smaller than 0'); }); }); @@ -184,13 +184,13 @@ describe('parameter', () => { it('should check max error', () => { var value = { string: 'hello' }; var rule = { string: {type: 'string', max: 4, min: 1 }}; - parameter.validate(rule, value)[0].message.should.equal('length should smaller than 4'); + parameter.validate(rule, value)[0].message.should.equal('length should not bigger than 4'); }); it('should check min error', () => { var value = { string: 'hello' }; var rule = { string: {type: 'string', max: 100, min: 10 }}; - parameter.validate(rule, value)[0].message.should.equal('length should bigger than 10'); + parameter.validate(rule, value)[0].message.should.equal('length should not smaller than 10'); }); it('should check format error', () => { @@ -432,7 +432,7 @@ describe('parameter', () => { { code: 'invalid', field: 'password', - message: 'length should bigger than 6' + message: 'length should not smaller than 6' } ]); @@ -449,7 +449,7 @@ describe('parameter', () => { { code: 'invalid', field: 'password', - message: 'length should bigger than 4' + message: 'length should not smaller than 4' } ]); }); @@ -622,13 +622,13 @@ describe('parameter', () => { it('should check max error', () => { var value = {array: [0, 1, 2, 3, 4]}; var rule = {array: {type: 'array', itemType: 'int', max: 4, min: 1}}; - parameter.validate(rule, value)[0].message.should.equal('length should smaller than 4'); + parameter.validate(rule, value)[0].message.should.equal('length should not bigger than 4'); }); it('should check min error', () => { var value = {array: [0, 1, 2, 3, 4]}; var rule = {array: {type: 'array', itemType: 'int', max: 100, min: 10}}; - parameter.validate(rule, value)[0].message.should.equal('length should bigger than 10'); + parameter.validate(rule, value)[0].message.should.equal('length should not smaller than 10'); }); it('should check itemType=object error', () => { @@ -1115,4 +1115,4 @@ describe('validate with options.convert', function() { }); }); }); -}); +}); \ No newline at end of file