valibot-schema-semver
Version:
Valibot schema for Semantic Versioning
1 lines • 390 B
JavaScript
import {custom}from'valibot';var s=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,r=e=>typeof e=="string"&&s.test(e),n=e=>`Invalid type: Expected Semantic Versioning received ${e.received}`,m=e=>custom(r,typeof e=="string"?()=>e:e||n);export{m as semver};