Feature Request: validate string as package version for Composer
Is there any plans to add functionality for checking whether the passed string is a valid package version for Composer?
You can use new VersionParser()->normalize() from https://github.com/composer/semver/blob/main/src/VersionParser.php#L108 that will throw if it's not parseable. That's the code Composer uses so it should do what you want I guess.
Oh, yeah, I saw that, and yeah, I used that exactly as you proposed, tho, I find it kinda odd - instead of just checking whether or not string is a version and getting (presumably) true/false answer, you had to ->normalize() it (not obvious solution by itself), but also you had to catch an exception after it. Not so... beautiful I guess? Not so straightforward, maybe. So, wouldn't it be more convenient to add some true/false method (that maybe do exactly that ->normalize() + catch) ?