PostalAddress builder
Creates a reusable PostalAddress structure. The PostalAddress builder injects @type, validates synchronously, and
rejects unknown properties.
Import
Section titled “Import”// Astro — shown first when Astro is selectedimport { PostalAddress } from '@unschema-graph/astro';
// Svelte 5import { PostalAddress } from '@unschema-graph/svelte';
// Core / Node.jsimport { PostalAddress } from '@unschema-graph/core';import { PostalAddressSchema } from '@unschema-graph/core';The PostalAddressSchema Zod schema is also exported for composition and advanced validation.
TypeScript types
Section titled “TypeScript types”import { PostalAddressSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type PostalAddressInput = SchemaInput<typeof PostalAddressSchema>;type PostalAddressOutput = SchemaOutput<typeof PostalAddressSchema, 'PostalAddress'>;Input properties
Section titled “Input properties”| Property | Input type | Required | Default / constraints |
|---|---|---|---|
@id |
string | No | — |
streetAddress |
string | No | — |
addressLocality |
string | No | — |
addressRegion |
string | No | — |
postalCode |
string | No | — |
addressCountry |
string | No | — |
postOfficeBoxNumber |
string | No | — |
The aliases above remain the exact authority for nested object types. The builder also accepts a
validation configuration as its second argument and always returns @type: 'PostalAddress'.
Minimal example
Section titled “Minimal example”import { PostalAddress } from '@unschema-graph/core';
const entity = PostalAddress({ "streetAddress": "1 Rue de Rivoli", "addressLocality": "Paris", "postalCode": "75001", "addressCountry": "FR"});Output
Section titled “Output”{ "@type": "PostalAddress", "streetAddress": "1 Rue de Rivoli", "addressLocality": "Paris", "postalCode": "75001", "addressCountry": "FR"}Relationships and recipes
Section titled “Relationships and recipes”- Related builders:
ImageObject,GeoCoordinates,ContactPoint - Used by: Local business, Events
- External sources: Schema.org PostalAddress
Common errors
Section titled “Common errors”- Passing an unknown property to the strict builder.
- Using source data that is missing a required property.
- Assuming valid Schema.org guarantees a search appearance.
Validation
Section titled “Validation”Use PostalAddress.safeParse(input) for external data. If Schema.org supports a property that
is not modeled yet, validate the entity first and then use withAdditionalProperties(). Never
pass invented properties to the strict builder.