Organization builder
Le builder Organization crée une entité Organization, 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 { Organization } from '@unschema-graph/astro';
// Svelte 5import { Organization } from '@unschema-graph/svelte';
// Core / Node.jsimport { Organization } from '@unschema-graph/core';import { OrganizationSchema } from '@unschema-graph/core';Le schéma Zod OrganizationSchema est également exporté pour la composition et la validation avancées.
Types TypeScript
Section intitulée « Types TypeScript »import { OrganizationSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type OrganizationInput = SchemaInput<typeof OrganizationSchema>;type OrganizationOutput = SchemaOutput<typeof OrganizationSchema, 'Organization'>;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 | — |
name |
string | Oui | non-empty |
legalName |
string | Non | — |
url |
string | Non | — |
logo |
string | ImageObject | Non | non-empty |
image |
string | ImageObject | Non | non-empty |
description |
string | Non | — |
sameAs |
string | Array |
Non | — |
address |
string | PostalAddress | EntityReference | Non | — |
contactPoint |
ContactPoint | Array<ContactPoint> | Non | — |
email |
string | Non | format: email |
telephone |
string | Non | — |
foundingDate |
string | number | Date | Non | non-empty |
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 Organization.
Exemple minimal
Section intitulée « Exemple minimal »import { Organization } from '@unschema-graph/core';
const entity = Organization({ "name": "Acme", "url": "https://example.com"});{ "@type": "Organization", "name": "Acme", "url": "https://example.com"}Relations et recettes
Section intitulée « Relations et recettes »- Builders liés :
Person,LocalBusiness,Restaurant,Store - Utilisé par : Blog et média, Site d’entreprise, SvelteKit et SSR, Core dans tout framework
- Sources externes : Schema.org Organization
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 Organization.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.