Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 1.05 KB

README.md

File metadata and controls

66 lines (42 loc) · 1.05 KB

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

Usage

Example:

local semver = import 'github.com/Duologic/semver-libsonnet/semver/main.libsonnet';

semver.parse('2.0.0-rc.1+build.123')

Output:

{
    "build": "build.123",
    "major": "2",
    "minor": "0",
    "patch": "0",
    "pre-release": "rc.1"
}

Index

Fields

fn parse

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

validate(semver)

PARAMETERS:

  • semver (string)

validate will parse and validate a Semantic Version from a string and return a boolean.