ConfigurableStringAttributeController
You get this controller when useAttribute(...) resolves a configurable string attribute — a free text input. You set it directly with a string, and can read the configured character limit for validation.
import { useAttribute } from "@expivi/product-configurator";
const attribute = useAttribute(configurator, attributeCid);
Setting a value
Pass the text straight to setValue(...), respecting the maximum character count:
const max = attribute.getMaxCharacters();
const text = userInput.slice(0, max);
attribute.setValue(text);
API
getMaxCharacters(): number
Returns the attribute's configured maximum character count. Reads settings.max_characters when the settings are of kind "string"; otherwise falls back to the default of 60.
attribute.getMaxCharacters(); // e.g. 60
This controller also overrides setValue(...)/parse(...):
setValue(value: string)
Writes the given string as the single configured value.
parse(data)
When parsing serialized data, the controller reads the first serialized value and applies it as-is through setValue(...).
For all other members (data, values, subscribe(...), serialize(), reset(), and more), see the Common Attribute API.