# Type Coercion — BrandApp Playground

> Eight helpers that pull typed values out of an EAV record's Record<string, unknown>.

- Canonical page: https://brandapp-playground.vercel.app/eav/coerce
- Markdown: https://brandapp-playground.vercel.app/eav/coerce.md
- SDK module: `@reopt-ai/brandapp-sdk/eav/coerce`

## Helpers

| Helper | Returns |
| --- | --- |
| `asString(value)` | `string \| undefined` |
| `asNumber(value)` | `number \| undefined`, NaN-safe |
| `asBoolean(value)` | `boolean \| undefined`, handles truthy/falsy strings |
| `asDate(value)` | `Date \| undefined` from ISO strings or timestamps |
| `asJson<T>(value)` | parsed JSON with type inference |
| `asStringArray(value)` | `string[]` from an array, JSON, or single value |
| `asEnum(value, allowed, fallback)` | a member of `allowed` |
| `asEnumOrUndefined(value, allowed)` | as above, without a fallback |

Every single-argument helper returns `undefined` for null, undefined, or invalid input.
Pair it with `?? fallback` when you need a default.

## Related

- [Typed Client](https://brandapp-playground.vercel.app/eav/typed.md)
- [Records](https://brandapp-playground.vercel.app/eav/records.md)

---

Index of every document: https://brandapp-playground.vercel.app/llms.txt
Single-file copy: https://brandapp-playground.vercel.app/llms-full.txt
HTTP API description: https://brandapp-playground.vercel.app/openapi.json
