Shared validation functions for message and topic validation
Used by both PAN Bus and PAN Client for consistency

Methods

isSerializable(data)

Shared validation functions for message and topic validation
Used by both PAN Bus and PAN Client for consistency
/
/**
Check if data is JSON-serializable

Parameters

Name Type Description
data * Data to check

Returns

boolean - True if serializable

checkSerializable(data)

Get detailed reason why data is not serializable

Parameters

Name Type Description
data * Data to check

Returns

{valid: boolean, error?: string - } Validation result

estimateSize(obj)

Estimate size of object in bytes

Parameters

Name Type Description
obj * Object to measure

Returns

number - Approximate size in bytes

validateTopic(topic)

Validate topic string

Parameters

Name Type Description
topic string Topic to validate

Returns

{valid: boolean, error?: string - } Validation result

validatePattern(pattern, options, [options.allowGlobalWildcard=true], [options.maxWildcards=5])

Validate subscription pattern

Parameters

Name Type Description
pattern string Pattern to validate
options Object Validation options
[options.allowGlobalWildcard=true] boolean Allow '*' pattern
[options.maxWildcards=5] number Max wildcard segments

Returns

{valid: boolean, error?: string - } Validation result

validateMessage(msg, limits, [limits.maxMessageSize=1048576], [limits.maxPayloadSize=524288])

Validate complete PAN message

Parameters

Name Type Description
msg Object Message to validate
limits Object Size limits
[limits.maxMessageSize=1048576] number Max total message size
[limits.maxPayloadSize=524288] number Max data payload size

Returns

{valid: boolean, error?: string - } Validation result

isElementAlive(el)

Check if element is still alive in DOM

Parameters

Name Type Description
el Element Element to check

Returns

boolean - True if element is in DOM

sanitizeError(error)

Sanitize error message for safe display

Parameters

Name Type Description
error * Error to sanitize

Returns

string - Safe error message