microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/appcenter/lib/codepush-node-sdk/dist/utils/validation-utils.js
18lines · modecode
| 1 | "use strict"; |
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | const semver = require("semver"); |
| 4 | // Check if the given string is a semver-compliant version number (e.g. '1.2.3') |
| 5 | // (missing minor/patch values will be added on server side to pass semver.satisfies check) |
| 6 | function isValidVersion(version) { |
| 7 | return !!semver.valid(version) || /^\d+\.\d+$/.test(version) || /^\d+$/.test(version); |
| 8 | } |
| 9 | exports.isValidVersion = isValidVersion; |
| 10 | // Allow plain integer versions (as well as '1.0' values) for now, e.g. '1' is valid here and we assume that it is equal to '1.0.0'. |
| 11 | function isValidRange(semverRange) { |
| 12 | return !!semver.validRange(semverRange); |
| 13 | } |
| 14 | exports.isValidRange = isValidRange; |
| 15 | function isValidRollout(rollout) { |
| 16 | return (rollout && rollout > 0 && rollout <= 100); |
| 17 | } |
| 18 | exports.isValidRollout = isValidRollout; |
| 19 | |