Actions35
- Cleaning Actions
- Coercion Actions
- Comparison Actions
- Increment Actions
- Parsing Actions
- Range Actions
- Sorting Actions
- Validation Actions
Overview
This node validates semantic version strings using the "semver" library. It checks if a given version string conforms to the semantic versioning specification and can also clean version strings by normalizing them.
Common scenarios where this node is useful include:
- Ensuring that version inputs in workflows are valid semantic versions before proceeding with deployment or release automation.
- Cleaning up user input or external data to produce normalized version strings.
- Validating version strings in CI/CD pipelines or package management workflows.
Practical example:
- Input a version string like
1.2.3-alphaand check if it is valid. - Clean a messy version string like
v1.2.3+buildto a normalized form1.2.3.
Properties
| Name | Meaning |
|---|---|
| Version | The semantic version string to validate or clean (e.g., "1.2.3", "2.0.0-beta"). |
| Options | Collection of options: |
| - Loose: Whether to use loose parsing for version strings (boolean). | |
| - Include Prerelease: Whether to include prerelease versions in range matching (boolean). |
Output
The output JSON contains the original input fields plus a result field with details depending on the operation:
For the Valid operation:
operation:"valid"version: The input version string.isValid: Boolean indicating if the version string is valid.parsedVersion: The normalized valid version string ornullif invalid.
For the Clean operation:
operation:"clean"version: The input version string.cleanedVersion: The cleaned and normalized version string ornullif cleaning failed.
No binary data is produced by this node.
Dependencies
- Uses the external
semvernpm package for semantic version parsing, validation, and cleaning. - No external API keys or services are required.
- No special environment variables or n8n credentials needed.
Troubleshooting
- Invalid version strings: If the input version string is not a valid semantic version, the
isValidfield will befalseandparsedVersionwill benull. Ensure the input follows semantic versioning format (e.g.,MAJOR.MINOR.PATCH). - Cleaning returns null: If cleaning fails, the
cleanedVersionwill benull. This usually means the input cannot be normalized into a valid semver string. - Loose parsing option: Enabling the "Loose" option allows more permissive parsing but may lead to unexpected results if the input is malformed.
- Error handling: If an error occurs during execution, the node will either throw an error or continue on fail based on configuration, returning the error message in the output JSON.