-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug [v2] BaseNumericInterface min 0 #361
Comments
Do you use Js or Ts? |
i use Ts, |
Fixed in v2.4.0 |
export class BaseNumericInterface extends NodeInterface implements IValidator {
public min?: number;
public max?: number;
}
When this.min is 0, the !this.min expression returns true, because in JavaScript, 0 is considered a false value. This means that the v >= this.min part is never evaluated when min is 0.
To correct this problem, you must explicitly check whether min and max are undefined rather than evaluating them as booleans.
public validate(v: number) {
return (this.min === undefined || v >= this.min) && (this.max === undefined || v <= this.max);
}
The text was updated successfully, but these errors were encountered: