Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating versions and version ranges #47

Open
r3ps4J opened this issue Nov 27, 2024 · 0 comments
Open

Validating versions and version ranges #47

r3ps4J opened this issue Nov 27, 2024 · 0 comments

Comments

@r3ps4J
Copy link

r3ps4J commented Nov 27, 2024

Hi!

I want to check if a semver version or version range string is valid. With node-semver I'm using valid(v) (for versions) and validRange(range) (for ranges) to do this. See the following Typescript code:

if (!semver.valid(actualVersion)) {
    return false;
}
if (!semver.validRange(requiredVersion)) {
    return false;
}

Can this be done with your library as well in C++?

For versions I think I can make use of the from_string methods and check the return or error, based on the following from the readme file:

// Non-member from string.
semver::version v5 = semver::from_string(s); // constexpr and may throw.
std::optional<version> v6 = semver::from_string_noexcept(s); // constexpr and no throw.

// From string.
semver::version v7;
v7.from_string(s); // constexpr and may throw.
bool success = v7.from_string_noexcept(s); // constexpr and no throw.

But I'm not sure if something similar is possible for version ranges. What would be the best way to recreate my typescript code in C++ using your library?

I'm a bit new to C++, so let me know if you need more info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant