Closed erwanito12 closed 7 months ago
Do you use Js or Ts?
If you use ts, you probably have the strictNullChecks
option set to false.
i use Ts,
tsconfig.json:
{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "moduleResolution": "node", "experimentalDecorators": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "useDefineForClassFields": true, "baseUrl": ".", "noImplicitAny": true, "sourceMap": true, "allowJs": true, "types": [ "webpack-env" ], "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx" ], "exclude": [ "node_modules" ] }
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); }