Skip to content

canCoerce

canCoerce(value, targetType) → boolean · Type

Check if a value can be coerced to a target type without error.

  • value (required): the value to test

  • targetType (required): target type as string — "number", "boolean", "date", etc.

utlx
canCoerce("123", "number")      // true
canCoerce("abc", "number")      // false
canCoerce("true", "boolean")    // true

Released under AGPL-3.0.