ContactPoint builder
Le builder ContactPoint crée une entité ContactPoint, injecte son @type,
valide les données de manière synchrone et rejette les propriétés inconnues.
// Astro — shown first when Astro is selectedimport { ContactPoint } from '@unschema-graph/astro';
// Svelte 5import { ContactPoint } from '@unschema-graph/svelte';
// Core / Node.jsimport { ContactPoint } from '@unschema-graph/core';import { ContactPointSchema } from '@unschema-graph/core';Le schéma Zod ContactPointSchema est également exporté pour la composition et la validation avancées.
Types TypeScript
Section intitulée « Types TypeScript »import { ContactPointSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type ContactPointInput = SchemaInput<typeof ContactPointSchema>;type ContactPointOutput = SchemaOutput<typeof ContactPointSchema, 'ContactPoint'>;Propriétés d’entrée
Section intitulée « Propriétés d’entrée »| Propriété | Type d’entrée | Obligatoire | Valeur par défaut / contraintes |
|---|---|---|---|
@id |
string | Non | — |
telephone |
string | Non | — |
contactType |
string | Non | — |
email |
string | Non | format: email |
areaServed |
string | Array |
Non | — |
availableLanguage |
string | Array |
Non | — |
url |
string | Non | — |
Les alias ci-dessus restent la référence exacte, notamment pour les objets imbriqués. Le builder
accepte aussi une configuration de validation en second argument et possède une sortie dont le
@type vaut toujours ContactPoint.
Exemple minimal
Section intitulée « Exemple minimal »import { ContactPoint } from '@unschema-graph/core';
const entity = ContactPoint({ "contactType": "customer support",});{ "@type": "ContactPoint", "contactType": "customer support",}Relations et recettes
Section intitulée « Relations et recettes »- Builders liés :
ImageObject,PostalAddress,GeoCoordinates - Utilisé par : aucune recette dédiée
- Sources externes : Schema.org ContactPoint
Erreurs fréquentes
Section intitulée « Erreurs fréquentes »- Passer une propriété inconnue au builder strict.
- Utiliser une donnée source privée d’une propriété obligatoire.
- Supposer qu’un Schema.org valide garantit un affichage dans la recherche.
Validation
Section intitulée « Validation »Utilisez ContactPoint.safeParse(input) pour les données externes. Pour une extension
Schema.org non encore modélisée, validez d’abord l’entité puis utilisez
withAdditionalProperties(). N’ajoutez jamais une propriété inventée au builder.