Skip to main content

validate_version

Function validate_version 

Source
pub fn validate_version(version: &str) -> bool
Expand description

契约模块 — 基于 quanttide-devops toolkit 的适配层。 校验版本号格式。

接受以下格式:

  • vX.Y.Z — 标准语义化版本
  • vX.Y.Z-prerelease — 带预发布后缀
  • scope/vX.Y.Z — 带作用域前缀
use quanttide_devops::contract::validate_version;
assert!(validate_version("v1.2.3"));
assert!(validate_version("cli/v0.5.0-rc.1"));
assert!(!validate_version("1.2.3"));        // 缺 v 前缀
assert!(!validate_version("v1.2"));          // 缺 patch
assert!(!validate_version(""));              // 空