Octopus.Client.Model.Versioning.StrictSemanticVersion.IsValidPart C# (CSharp) Method

IsValidPart() static private method

static private IsValidPart ( char chars, bool allowLeadingZeros ) : bool
chars char
allowLeadingZeros bool
return bool
        internal static bool IsValidPart(char[] chars, bool allowLeadingZeros)
        {
            var result = true;

            if (chars.Length == 0)
            {
                // empty labels are not allowed
                result = false;
            }

            // 0 is fine, but 00 is not. 
            // 0A counts as an alpha numeric string where zeros are not counted
            if (!allowLeadingZeros
                && chars.Length > 1
                && chars[0] == '0'
                && chars.All(c => Char.IsDigit(c)))
            {
                // no leading zeros in labels allowed
                result = false;
            }
            else
            {
                result &= chars.All(c => IsLetterOrDigitOrDash(c));
            }

            return result;
        }

Same methods

StrictSemanticVersion::IsValidPart ( string s, bool allowLeadingZeros ) : bool