• JMap.Util.checkJmapId

    Throws an Error if the passed Id is not a valid JMap Id, otherwise does nothing. You can use this method as a safeguard in your methods that accept JMap Ids. JMap.Util.checkJmapId always run a strict check on the passed value, i.e. the string "123" will not pass. If you want the value to be compliant, you can use JMap.Util.getJmapIdAsIntegerIfPossible to transform it.

    Parameters

    • id: any

      The JMap Id to validate

    • Optional message: string

      Optional message that will be used in the thrown error if the passed value doesn't pass the check.

    Returns void

    Throws

    Error if the passed value is not a valid JMap Id

    Example

    JMap.Util.checkJmapId("")
    // Error thrown "Invalid JMap Id"

    JMap.Util.checkJmapId("", "My custom error message")
    // Error thrown "My custom error message"

    JMap.Util.checkJmapId(4)
    // undefined