| 5 | } from '../types'; |
| 6 | |
| 7 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…