A2UICore.Validation.ReservedKeys (A2UICore v0.1.1)

Copy Markdown View Source

The v1.0 reserved-key rule for dynamic objects.

In v1.0 a key that starts with a single @ is a protocol directive (@path, @call). Any other @-prefixed key must be escaped by doubling the prefix (@@note stands for the literal key @note); unescape/1 undoes that when a value is resolved.

Summary

Functions

Checks that every single-@ key of a dynamic object is a known directive. Protocol versions before v1.0 have no reserved keys.

Whether key starts with a single @ (not the escaped @@).

Removes one @ from an escaped key ("@@path" → "@path").

Functions

check(keys, version)

(since 0.1.0)
@spec check([String.t()], String.t() | nil) :: :ok | {:error, A2UICore.Error.t()}

Checks that every single-@ key of a dynamic object is a known directive. Protocol versions before v1.0 have no reserved keys.

directive_like?(key)

(since 0.1.0)
@spec directive_like?(String.t()) :: boolean()

Whether key starts with a single @ (not the escaped @@).

iex> A2UICore.Validation.ReservedKeys.directive_like?("@path")
true
iex> A2UICore.Validation.ReservedKeys.directive_like?("@@path")
false

unescape(key)

(since 0.1.0)
@spec unescape(String.t()) :: String.t()

Removes one @ from an escaped key ("@@path" → "@path").