UNPKG

@mitre-attack/attack-data-model

Version:

A TypeScript API for the MITRE ATT&CK data model

43 lines (39 loc) 1.68 kB
import { z } from 'zod'; /** * This module is intended for utility schemas - common schemas that aren't semantically predicated on ATT&CK or STIX * These are generalized, common schemas, meant to promote composability through schema re-use */ /** * A Zod schema for validating non-empty, trimmed strings. * * This schema ensures that: * - The input is a string type * - Leading and trailing whitespace is removed * - At least one non-whitespace character remains after trimming * * @example * ```typescript * nonEmptyRequiredString.parse("hello"); // "hello" * nonEmptyRequiredString.parse(" hello "); // "hello" * nonEmptyRequiredString.parse(""); // throws error * nonEmptyRequiredString.parse(" "); // throws error * ``` */ declare const nonEmptyRequiredString: z.ZodString; declare const emptyStixListErrorMessage = "Empty lists are prohibited in STIX and MUST NOT be used as a substitute for omitting the property if it is optional. The list MUST be present and MUST have at least one value."; /** * A STIX-compliant list schema for non-empty strings. * * This is a convenience schema that combines `z.array` with `nonEmptyRequiredString`, * creating a common pattern used throughout STIX objects for string array properties. * * @example * ```typescript * stixListOfString.parse(["foo", "bar"]); // ["foo", "bar"] * stixListOfString.parse(["foo", " bar "]); // ["foo", "bar"] (trimmed) * stixListOfString.parse([]); // throws error * stixListOfString.parse(["foo", ""]); // throws error * ``` */ declare const stixListOfString: z.ZodArray<z.ZodString>; export { emptyStixListErrorMessage, nonEmptyRequiredString, stixListOfString };