Actions35
- Cleaning Actions
- Coercion Actions
- Comparison Actions
- Increment Actions
- Parsing Actions
- Range Actions
- Sorting Actions
- Validation Actions
Overview
This node provides utilities for semantic versioning (semver) management, specifically focusing on coercion of version strings to semver format in the "Coercion" resource with the "Coerce" operation. It takes a version string input and attempts to convert or coerce it into a valid semantic version object.
This is useful when dealing with version strings that may not strictly follow semver rules but need to be normalized or interpreted as semver versions for further processing, comparison, or validation.
Practical examples:
- Converting loosely formatted version strings like
"v1.2"or"version 1.2.3-beta"into proper semver objects. - Normalizing user input or external data feeds where version strings are inconsistent.
- Preparing version strings for downstream operations such as sorting, incrementing, or range checking.
Properties
| Name | Meaning |
|---|---|
| Version | The version string to process and coerce into semver format. Example: 1.2.3 |
| Options | Collection of options affecting coercion behavior: |
| Loose | Whether to use loose parsing for version strings (true or false) |
| Include Prerelease | Whether to include prerelease versions in range matching (true or false) |
| RTL (Right to Left) | Whether to coerce version strings from right to left (true or false) |
Output
The output JSON contains the following fields:
operation: Always"coerce"indicating the performed operation.version: The original input version string.result: The coerced semver object or string representing the normalized version. This will benullif coercion fails.
Example output JSON snippet:
{
"operation": "coerce",
"version": "v1.2",
"result": "1.2.0"
}
No binary data output is produced by this node.
Dependencies
- Uses the external
semverlibrary for all semantic version parsing and coercion logic. - No external API keys or services are required.
- No special environment variables or n8n credentials are needed.
Troubleshooting
Common issues:
- Input version strings that are too malformed may fail to coerce, resulting in a
nullresult. - Misconfiguration of options like
looseorrtlmight lead to unexpected coercion results.
- Input version strings that are too malformed may fail to coerce, resulting in a
Error messages:
- If an unknown resource or operation is selected, the node throws an error indicating the unknown resource.
- Errors during coercion typically propagate as messages describing invalid version formats.
Resolution tips:
- Ensure the input version string is at least somewhat recognizable as a version.
- Adjust the
Looseoption to allow more permissive parsing if strict coercion fails. - Use the
RTLoption if the version string format requires right-to-left interpretation.