Edit: this seem to be enough ```if (!JsNumber.isSa...
# javascript
e
Edit: this seem to be enough
Copy code
if (!JsNumber.isSafeInteger(value)) {
  throw IllegalArgumentException("Invalid number: $value")
}
Given an exported function like
Copy code
fun writeInt(value: Int)
And being that in JS (or even TS) there is no guarantee the submitted
number
is indeed an integer , what's the best path to take to ensure data correctness?
t
Which type do you have at start?
e
@turansky that's the issue, it's submitted externally and in TypeScript it's only
number
, so a user can submit any kind. But that check works perfectly for my needs.
t
You can use
Number.toInt()
+ check