spdx-expression-validate
validate SPDX license expressions
This package has a good security score with no known vulnerabilities.
Community Reviews
Simple, focused validator that does one thing well with minimal fuss
The error messages are clear and specific, pointing out exactly what's wrong with malformed expressions like 'MIT + Apache' (should be 'OR' not '+'). It correctly handles complex expressions with parentheses and compound operators. The one gotcha I hit was that it only validates syntax, not whether license identifiers actually exist in the SPDX list - you'll need spdx-correct or spdx-expression-parse for that.
Documentation is minimal but sufficient since the API surface is tiny. The README gives you everything you need in about 30 seconds of reading. No Stack Overflow presence to speak of, but honestly, you won't need it. The package hasn't been updated since 2019, but SPDX expression syntax is stable, so this isn't concerning for this particular use case.
Best for: Projects needing to validate SPDX license expression syntax in package managers, build tools, or license compliance checkers.
Avoid if: You need to validate that license identifiers themselves are real SPDX IDs (use spdx-correct or spdx-expression-parse instead).
Simple, focused validator that does one thing well with minimal fuss
The error messages are clear and actionable, like "EMPTY PARENTHESES" or "UNKNOWN LICENSE". When debugging license expression parsing issues, the offset property tells you exactly where things went wrong. It correctly handles all the SPDX 2.0 operators (AND, OR, WITH) and catches malformed expressions like unbalanced parentheses or double operators.
The main limitation is lack of examples beyond the basic usage in the README. There's no guidance on integrating with build systems or handling edge cases. The package hasn't been updated since 2019, but SPDX expression syntax is stable, so this isn't really a concern for day-to-day use.
Best for: Projects needing straightforward SPDX license expression validation with minimal overhead and clear error reporting.
Avoid if: You need to parse or manipulate license expressions beyond validation, or require extensive documentation and examples.
Simple, focused validator that does one thing well with minimal friction
Error messages are practical and specific, pointing to exact positions in the string where validation fails. When you mess up parentheses or use invalid operators, you get messages like 'Expected AND, OR, or WITH' with offset information. This makes debugging user input straightforward. The package handles all the nuances of SPDX expression syntax including the WITH operator for license exceptions.
The main limitation is that it only validates syntax, not whether license IDs are actually valid SPDX identifiers. You'd need spdx-expression-parse or spdx-correct for that. Documentation is minimal but honestly sufficient given the simplicity. The package hasn't been updated since 2019, but SPDX expression syntax is stable, so this isn't concerning for this specific use case.
Best for: Projects that need to validate user-supplied SPDX license expression syntax before parsing or storage.
Avoid if: You need to validate that license identifiers are legitimate SPDX IDs, not just syntactically correct expressions.
Sign in to write a review
Sign In