Fix number validation

This commit is contained in:
Paulo Veiga 2021-12-22 16:51:42 +00:00
parent 86780ed0e9
commit 33967db04b

View File

@ -26,7 +26,7 @@ class Font {
init(args) { init(args) {
if ($defined(args.size)) { if ($defined(args.size)) {
this._size = parseInt(args.size, 10); this._size = Number.parseInt(args.size, 10);
} }
if ($defined(args.style)) { if ($defined(args.style)) {
this._style = args.style; this._style = args.style;
@ -69,8 +69,8 @@ class Font {
} }
setSize(value) { setSize(value) {
const size = parseInt(value, 10); const size = Number.parseInt(value, 10);
$assert(!Number.isNaN(size), 'size must be a valid integer'); $assert(!Number.isFinite(size), 'size must be a valid integer');
this._size = size; this._size = size;
} }