Closed roosephu closed 8 years ago
which version of your koa-validate? please try latest version .
I'm now using koa-validate v1.0.3.
Here are some code I see in this repo, from Line 502 to 508:
Validator.prototype.toFloat = function(tip) {
this.isFloat(tip);
if (!this.hasError()) {
this.value = this.params[this.key] = v.toFloat(this.value);
}
return this;
};
If this.value
is a number, it'll throw an error.
thanks, this bug has been fixed at 1.0.4
When calling
isFloat
, the library checks whether the object is already a number. But when callingtoFloat
the library doesn't check that, so passing a number tov.toFloat
will result inTypeError: This library (validator.js) validates strings only
.It may not be a big problem, since we should know the type of each object before validating.