Aller au contenu

HowToSection builder

Le builder HowToSection crée une entité HowToSection, injecte son @type, valide les données de manière synchrone et rejette les propriétés inconnues.

// Astro — shown first when Astro is selected
import { HowToSection } from '@unschema-graph/astro';
// Svelte 5
import { HowToSection } from '@unschema-graph/svelte';
// Core / Node.js
import { HowToSection } from '@unschema-graph/core';
import { HowToSectionSchema } from '@unschema-graph/core';

Le schéma Zod HowToSectionSchema est également exporté pour la composition et la validation avancées.

import {
HowToSectionSchema,
type SchemaInput,
type SchemaOutput,
} from '@unschema-graph/core';
type HowToSectionInput = SchemaInput<typeof HowToSectionSchema>;
type HowToSectionOutput = SchemaOutput<typeof HowToSectionSchema, 'HowToSection'>;
Propriété Type d’entrée Obligatoire Valeur par défaut / contraintes
@id string Non —
name string Oui non-empty
itemListElement Array Oui —

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 HowToSection.

import { HowToSection } from '@unschema-graph/core';
const entity = HowToSection({
"name": "Deployment",
"itemListElement": [
{
"text": "Build the Astro project."
}
]
});
{
"@type": "HowToSection",
"name": "Deployment",
"itemListElement": [
{
"@type": "HowToStep",
"text": "Build the Astro project."
}
]
}
  • 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.

Utilisez HowToSection.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.