MCPcopy
hub / github.com/markdoc/markdoc / Class

Class Class

src/schema-types/class.ts:7–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5} from '../types';
6
7export class Class implements CustomAttributeTypeInterface {
8 validate(value: any, _config: Config, key: string): ValidationError[] {
9 if (typeof value === 'string' || typeof value === 'object') return [];
10
11 return [
12 {
13 id: 'attribute-type-invalid',
14 level: 'error',
15 message: `Attribute '${key}' must be type 'string | object'`,
16 },
17 ];
18 }
19
20 transform(value: any) {
21 if (!value || typeof value === 'string') return value;
22
23 const classes = [];
24 for (const [k, v] of Object.entries(value ?? {})) if (v) classes.push(k);
25 return classes.join(' ');
26 }
27}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…