File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ Deno.test("semver", async test => {
3434 assertEquals ( semver . parse ( "1" ) ?. toString ( ) , "1.0.0" )
3535 } )
3636
37+ await test . step ( "isValidSemVer" , ( ) => {
38+ assert ( semver . isValid ( "1.2.3.4.5" ) )
39+ assert ( semver . isValid ( "1a" ) )
40+ assert ( semver . isValid ( "20.4" ) )
41+ assert ( semver . isValid ( "2023.05.10" ) )
42+ assertFalse ( semver . isValid ( "a" ) )
43+ assertFalse ( semver . isValid ( "!#!@#!@#" ) )
44+ } )
45+
3746 await test . step ( "satisfies" , ( ) => {
3847 assertEquals ( new semver . Range ( "=3.1.0" ) . max ( [ new SemVer ( "3.1.0" ) ] ) , new SemVer ( "3.1.0" ) )
3948 } )
Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ export function parse(input: string) {
115115 }
116116}
117117
118+ /// determines if the input is in fact a valid semantic version
119+ export function isValid ( input : string ) {
120+ return parse ( input ) !== undefined
121+ }
122+
118123/// we don’t support as much as node-semver but we refuse to do so because it is badness
119124export class Range {
120125 // contract [0, 1] where 0 != 1 and 0 < 1
You can’t perform that action at this time.
0 commit comments