Skip to content

Commit

Permalink
Merge pull request #531 from eloquence/patch-1
Browse files Browse the repository at this point in the history
Correct string length validation error messages - PR by @eloquence
  • Loading branch information
neumino authored Jul 16, 2016
2 parents 10c702d + c17d88e commit b80fc82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/type/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ TypeString.prototype.validate = function(str, prefix, options) {
}
else {
if ((this._min !== -1) && (this._min > str.length)){
throw new Errors.ValidationError("Value for "+prefix+" must be longer than "+this._min+".")
throw new Errors.ValidationError("Value for "+prefix+" must not be shorter than "+this._min+".")
}
if ((this._max !== -1) && (this._max < str.length)){
throw new Errors.ValidationError("Value for "+prefix+" must be shorter than "+this._max+".")
throw new Errors.ValidationError("Value for "+prefix+" must not be longer than "+this._max+".")
}
if ((this._length !== -1) && (this._length !== str.length)){
throw new Errors.ValidationError("Value for "+prefix+" must be a string with "+this._length+" characters.")
Expand Down
4 changes: 2 additions & 2 deletions test/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('Chainable types', function(){
var doc = new Model({ id: 'a'});
doc.validate();
}, function(error) {
return (error instanceof Errors.ValidationError) && (error.message === "Value for [id] must be longer than 2.");
return (error instanceof Errors.ValidationError) && (error.message === "Value for [id] must not be shorter than 2.");
});
});
it('String - min - good', function(){
Expand All @@ -288,7 +288,7 @@ describe('Chainable types', function(){
var doc = new Model({ id: 'abcdefgh'});
doc.validate();
}, function(error) {
return (error instanceof Errors.ValidationError) && (error.message === "Value for [id] must be shorter than 5.");
return (error instanceof Errors.ValidationError) && (error.message === "Value for [id] must not be longer than 5.");
});
});
it('String - max - good', function(){
Expand Down

0 comments on commit b80fc82

Please sign in to comment.