Chi Component Validation Schemas
How to Validate
When validating component usage:
- •Identify the base class (e.g.,
chi-buttonfromclass="chi-button -primary -lg") - •Look up the schema in schemas.json by base class key (e.g.,
chi-button) - •Check modifiers against
allowedModifiers-- flag any not in the list - •Check conflicts in
conflictingModifiersgroups -- only one from each group is allowed - •Verify count against
maxModifierslimit - •Check attributes:
requiredAttributesmust be present,recommendedAttributesshould be suggested - •Check accessibility: verify
accessibility.requiredRolesandaccessibility.requiredAriaare present - •Suggest Web Component if
webComponentTagexists -- always recommend it
Note: If a schema is missing conflictingModifiers, maxModifiers, or requiredAttributes, treat them as empty/unlimited. Not all schemas have every field populated.
Validation Rules
Modifier Validation
- •Only modifiers in
allowedModifiersare valid. Unknown modifiers are errors. - •Within each
conflictingModifiersgroup (e.g.,colors: ["-primary", "-secondary"]), only ONE modifier can be used. - •Total modifier count must not exceed
maxModifiers.
Attribute Validation
- •
requiredAttributesmust be present. Missing = error. - •
recommendedAttributesshould be suggested. Missing = warning.
Accessibility Validation
- •Check
accessibility.requiredRolesare present - •Check
accessibility.requiredAriaattributes exist - •Report
accessibility.keyboardSupportandaccessibility.focusManagementinfo - •Note: Web Components handle most accessibility automatically. If suggesting a WC, note that ARIA attributes are built-in.
Error Severity
| Issue | Severity |
|---|---|
| Unknown modifier | Error |
| Conflicting modifiers | Error |
| Exceeds maxModifiers | Warning |
| Missing required attribute | Error |
| Missing recommended attribute | Warning |
| Has Web Component equivalent | Info (suggest migration) |
Workflow
When user asks to validate a component or you review Chi HTML:
- •Parse the HTML to identify base class and modifiers (split
classattribute, base =chi-*, modifiers =-*) - •Look up schema from schemas.json
- •Run all validation checks
- •Return errors, warnings, and Web Component suggestion
If no schema exists for the component, note that and still check for common anti-patterns (single-dash syntax, conflicting colors, etc.).
Response Format
code
Component: chi-button Valid: Yes/No Errors: [list of errors with severity] Warnings: [list of warnings] Suggestion: Use <chi-button color="primary" size="lg"> instead (Web Component) Accessibility: Enter/Space to activate, receives focus in tab order