Functions
assertNumberIsBetweenForCodec
assertNumberIsBetweenForCodec(
codecDescription
,min
,max
,value
):void
Ensures that a given number falls within a specified range.
If the number is outside the allowed range, an error is thrown. This function is primarily used to validate values before encoding them in a codec.
Parameters
Parameter | Type | Description |
---|---|---|
codecDescription | string | A string describing the codec that is performing the validation. |
min | number | bigint | The minimum allowed value (inclusive). |
max | number | bigint | The maximum allowed value (inclusive). |
value | number | bigint | The number to validate. |
Returns
void
Throws
SolanaError if the value is out of range.
Examples
Validating a number within range.
Throwing an error for an out-of-range value.