PHPackages                             kanopi/drupal-sdc-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. kanopi/drupal-sdc-validator

ActiveLibrary[CLI &amp; Console](/categories/cli)

kanopi/drupal-sdc-validator
===========================

CLI tool to validate Drupal Single Directory Component (.component.yml) files.

v1.0.1(6mo ago)11.4k↓50%MITPHPPHP &gt;=8.1

Since Oct 15Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/kanopi/drupal-sdc-validator)[ Packagist](https://packagist.org/packages/kanopi/drupal-sdc-validator)[ RSS](/packages/kanopi-drupal-sdc-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Drupal SDC Validator
====================

[](#drupal-sdc-validator)

A CLI tool to validate [Drupal Single Directory Component (SDC)](https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components) `.component.yml` files for structure and schema compliance.

This validator helps you ensure your SDC metadata files follow the [Drupal core schema](https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata-full.schema.json), and reports any missing fields, invalid structures, or schema violations.

---

🚀 Features
----------

[](#-features)

- ✅ Validates `.component.yml` files recursively in any path
- ✅ Validates against Drupal core's `metadata-full.schema.json`
- ✅ Checks for name collisions between props and slots
- ✅ Validates non-string property types
- ✅ Supports class/interface type validation (like Drupal core)
- ✅ Optional `--enforce-schemas` flag for strict validation
- ✅ JSON Schema validation via [`justinrainbow/json-schema`](https://github.com/justinrainbow/json-schema)
- ✅ Works as a Composer-installed CLI tool (`vendor/bin/validate-sdc`)
- ✅ Caches remote schema for 24 hours for faster re-runs
- ✅ Error messages match Drupal core's ComponentValidator format

---

🧩 Installation
--------------

[](#-installation)

```
composer require --dev kanopi/drupal-sdc-validator
```

---

📖 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

Validate components in one or more directories:

```
# Single directory
vendor/bin/validate-sdc web/themes/custom/your_theme/components

# Multiple directories
vendor/bin/validate-sdc web/themes/custom/theme1/components web/modules/custom/module1/components
```

### Enforce Schema Validation

[](#enforce-schema-validation)

Use the `--enforce-schemas` flag to require schema definitions (similar to Drupal modules):

```
vendor/bin/validate-sdc web/modules/custom/your_module/components --enforce-schemas
```

This will fail validation if any component is missing a `props` schema definition.

### Validation Modes

[](#validation-modes)

**Default (Lenient Mode)**

- Components **without** `props` are valid (matches Drupal theme behavior)
- Components **with** `props` are validated against the schema

**Strict Mode (`--enforce-schemas`)**

- **All** components must have `props` defined (matches Drupal module behavior)
- Use this for module components or when you want strict validation

### Example Output

[](#example-output)

```
web/themes/custom/mytheme/components/button/button.component.yml has validation errors:
  • The component "button" declared [variant] both as a prop and as a slot. Make sure to use different names.
  • [props.properties.size.type] The property type must be a string.

============================================================
✗ Validation failed!
  Total files checked: 15
  Files with errors: 1

```

---

🔍 Validation Rules
------------------

[](#-validation-rules)

This validator implements the same validation logic as Drupal core's `ComponentValidator`:

### Name Collision Detection

[](#name-collision-detection)

Checks that props and slots don't share the same names.

### Non-String Type Validation

[](#non-string-type-validation)

Ensures all property types are declared as strings (not integers, booleans, etc.).

### Class/Interface Type Support

[](#classinterface-type-support)

Validates custom class/interface types exist in the codebase (e.g., `Drupal\Core\Url`).

### Schema Enforcement

[](#schema-enforcement)

With `--enforce-schemas`, requires all components to have prop schemas defined.

### Empty Properties Handling

[](#empty-properties-handling)

Properly handles empty `properties: {}` declarations.

---

🧪 Integration with Your Project
-------------------------------

[](#-integration-with-your-project)

### Add Composer Scripts

[](#add-composer-scripts)

Once installed, add these scripts to your project's `composer.json` for easy access:

```
{
  "scripts": {
    "validate-sdc": [
      "@php vendor/bin/validate-sdc web/themes/custom"
    ],
    "validate-sdc-enforce": [
      "@php vendor/bin/validate-sdc web/themes/custom --enforce-schemas"
    ]
  }
}
```

Then run:

```
# Lenient mode (themes)
composer validate-sdc

# Strict mode (modules)
composer validate-sdc-enforce
```

**Note:** Using `@php` ensures exit codes are properly propagated, making validation failures fail CI/CD pipelines.

---

📝 License
---------

[](#-license)

MIT

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

208d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf9dca5c46910be861bb00920034637b5a36a1f6277413be6817a50a1ce6fc74?d=identicon)[kanopi\_studios](/maintainers/kanopi_studios)

---

Top Contributors

[![asipple1](https://avatars.githubusercontent.com/u/4413018?v=4)](https://github.com/asipple1 "asipple1 (20 commits)")[![paulsheldrake](https://avatars.githubusercontent.com/u/1062456?v=4)](https://github.com/paulsheldrake "paulsheldrake (1 commits)")

---

Tags

clivalidatorcomponentsdrupalymlsdc

### Embed Badge

![Health badge](/badges/kanopi-drupal-sdc-validator/health.svg)

```
[![Health](https://phpackages.com/badges/kanopi-drupal-sdc-validator/health.svg)](https://phpackages.com/packages/kanopi-drupal-sdc-validator)
```

###  Alternatives

[pantheon-systems/terminus

A command line interface for Pantheon

3391.5M13](/packages/pantheon-systems-terminus)[drupal/console-core

Drupal Console Core

13514.7M12](/packages/drupal-console-core)[acmephp/acmephp

Let's Encrypt client written in PHP

649155.1k](/packages/acmephp-acmephp)[j13k/yaml-lint

A compact command line utility for checking YAML file syntax

161.1M19](/packages/j13k-yaml-lint)[jigarius/drall

Drall is a command-line utility to run drush on multi-site Drupal installations.

35105.9k](/packages/jigarius-drall)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
