OptionalcauseOptionalstackThe index of the first invalid character in the string.
Always true: identifies an InvalidCharacterError without instanceof.
The string that was forged.
StaticcreateCreates the error for a string with an invalid character.
The system that forged the string.
The string that was forged.
The index of the first invalid character.
StaticisIndicates whether the argument provided is a built-in Error instance or not.
Returned (never thrown) by
forgewhen the string has a character that is not a digit of the system: neither thezeronor a character fromfirsttolast. Check positions coming from outside (an API, a form) withforgebefore storing them.Example