AggregateOffer builder
Le builder AggregateOffer crée une entité AggregateOffer, 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 { AggregateOffer } from '@unschema-graph/astro';
// Svelte 5import { AggregateOffer } from '@unschema-graph/svelte';
// Core / Node.jsimport { AggregateOffer } from '@unschema-graph/core';import { AggregateOfferSchema } from '@unschema-graph/core';Le schéma Zod AggregateOfferSchema est également exporté pour la composition et la validation avancées.
Types TypeScript
Section intitulée « Types TypeScript »import { AggregateOfferSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type AggregateOfferInput = SchemaInput<typeof AggregateOfferSchema>;type AggregateOfferOutput = SchemaOutput<typeof AggregateOfferSchema, 'AggregateOffer'>;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 | — |
lowPrice |
number | string | Oui | — |
highPrice |
number | string | Non | — |
priceCurrency |
string | Oui | minimum length: 3; maximum length: 3 |
offerCount |
number | string | Non | — |
offers |
Offer | AggregateOffer | Array<Offer | AggregateOffer> | 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 AggregateOffer.
Exemple minimal
Section intitulée « Exemple minimal »import { AggregateOffer } from '@unschema-graph/core';
const entity = AggregateOffer({ "lowPrice": 79, "highPrice": 129, "priceCurrency": "EUR", "offerCount": 3});{ "@type": "AggregateOffer", "lowPrice": 79, "highPrice": 129, "priceCurrency": "EUR", "offerCount": 3}Relations et recettes
Section intitulée « Relations et recettes »- Builders liés :
Product,Offer,Service,JobPosting - Utilisé par : E-commerce
- Sources externes : Schema.org AggregateOffer
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 AggregateOffer.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.