Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duologic/semver-libsonnet
Jsonnet library to parse and validate Semantic Versioning
https://github.com/duologic/semver-libsonnet
jsonnet jsonnet-lib semantic-versioning semver semver-parser
Last synced: about 1 month ago
JSON representation
Jsonnet library to parse and validate Semantic Versioning
- Host: GitHub
- URL: https://github.com/duologic/semver-libsonnet
- Owner: Duologic
- License: apache-2.0
- Created: 2024-08-23T14:36:26.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-16T12:43:11.000Z (3 months ago)
- Last Synced: 2024-10-21T05:54:52.355Z (3 months ago)
- Topics: jsonnet, jsonnet-lib, semantic-versioning, semver, semver-parser
- Language: Jsonnet
- Homepage:
- Size: 56.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# semver
Jsonnet library to parse and validate Semantic Versioning.
Implemented according spec Semantic Versioning 2.0.0
Using BNF: https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions
## Install
```
jb install github.com/Duologic/semver-libsonnet/semver@main
```
## UsageExample:
```jsonnet
local semver = import 'github.com/Duologic/semver-libsonnet/semver/main.libsonnet';semver.parse('2.0.0-rc.1+build.123')
```
Output:
```json
{
"build": "build.123",
"major": "2",
"minor": "0",
"patch": "0",
"pre-release": "rc.1"
}
```## Index
* [`fn parse(semver)`](#fn-parse)
* [`fn validate(semver)`](#fn-validate)## Fields
### fn parse
```jsonnet
parse(semver)
```PARAMETERS:
* **semver** (`string`)
`parse` will parse and validate a Semantic Version from a string and returning an object. It'll throw an assertion if the string is not valid.
### fn validate```jsonnet
validate(semver)
```PARAMETERS:
* **semver** (`string`)
`validate` will parse and validate a Semantic Version from a string and return a boolean.