API reference > @kontsedal/olas-core > FieldTransform
FieldTransform type
A bidirectional T ↔ string transform, suitable for HTML input bindings where DOM values are always strings.
parse(raw) converts the input's string value into the field's type;format(value) converts the field's typed value back into a string for the input. Both must be pure — useFieldInput calls them on every render and every input event respectively.
ts
const numberTransform: FieldTransform<number> = {
parse: (raw) => Number(raw),
format: (v) => String(v),
}Signature:
typescript
type FieldTransform<T> = {
parse: (raw: string) => T;
format: (value: T) => string;
};