spectra_string (spectra v0.11.1)

View Source

Summary

Functions

Converts a string value to an Erlang value based on a type specification.

Converts an Erlang value to a string based on a type specification.

Functions

from_string(TypeInfo, Type, String, Config)

-spec from_string(TypeInfo :: spectra:type_info(),
                  Type :: spectra:sp_type(),
                  String :: list(),
                  Config :: spectra:sp_config()) ->
                     {ok, dynamic()} | {error, [spectra:error()]}.

Converts a string value to an Erlang value based on a type specification.

This function validates the given string value against the specified type definition and converts it to the corresponding Erlang value.

Returns

{ok, ErlangValue} if conversion succeeds, or {error, Errors} if validation fails

to_string(TypeInfo, Type, Data, Config)

-spec to_string(TypeInfo :: spectra:type_info(),
                Type :: spectra:sp_type(),
                Data :: dynamic(),
                Config :: spectra:sp_config()) ->
                   {ok, string()} | {error, [spectra:error()]}.

Converts an Erlang value to a string based on a type specification.

This function validates the given Erlang value against the specified type definition and converts it to a string representation.

Returns

{ok, String} if conversion succeeds, or {error, Errors} if validation fails