예제 #1
0
        /// <summary>
        /// Checks that an OwnershipChallenge id is in the correct format
        /// </summary>
        /// <returns>bool indicating whether the id is valid</returns>
        /// <param name="id">The id to be validated</param>
        public static bool ValidateChallengeID(string id)
        {
            bool isValid = true;

            // split and ensure has correct format
            string[] idSplit = id.Split('_');
            if (idSplit.Length != 2)
            {
                isValid = false;
            }

            // must start with 'Challenge'
            else if (!idSplit[0].Equals("Challenge"))
            {
                isValid = false;
            }

            // must end with numbers
            else if (!Utility_Methods.CheckStringValid("numbers", idSplit[1]))
            {
                isValid = false;
            }

            return(isValid);
        }
예제 #2
0
        /// <summary>
        /// Checks that a JournalEntry personae entry is in the correct format
        /// </summary>
        /// <returns>bool indicating whether the personae entry is valid</returns>
        /// <param name="personae">The personae entry to be validated</param>
        public static bool ValidateJentryPersonae(string personae)
        {
            bool isValid = true;

            // split using'|'
            string[] persSplit = personae.Split('|');
            if (persSplit.Length != 2)
            {
                isValid = false;
            }

            // 1st section must be valid character ID or 'all'
            else if ((!persSplit[0].Equals("all")) && (!Utility_Methods.ValidateCharacterID(persSplit[0])))
            {
                isValid = false;
            }

            // 2nd section must be all letters
            else if (!Utility_Methods.CheckStringValid("letters", persSplit[1]))
            {
                isValid = false;
            }

            return(isValid);
        }
예제 #3
0
        /// <summary>
        /// Checks that a nationality id is in the correct format
        /// </summary>
        /// <returns>bool indicating whether the id is valid</returns>
        /// <param name="nat">The id to be validated</param>
        public static bool ValidateNationalityID(string nat)
        {
            bool isValid = true;

            // 1-3 in length
            if ((nat.Length < 1) || (nat.Length > 3))
            {
                isValid = false;
            }

            // letters only
            if (!Utility_Methods.CheckStringValid("letters", nat))
            {
                isValid = false;
            }

            return(isValid);
        }
예제 #4
0
        /// <summary>
        /// Checks that a Language id is in the correct format
        /// </summary>
        /// <returns>bool indicating whether the id is valid</returns>
        /// <param name="id">The id to be validated</param>
        /// <param name="langType">The type of id to be validated (lang, baseLang)</param>
        public static bool ValidateLanguageID(string id, string langType = "lang")
        {
            bool isValid = true;

            // split and ensure has correct format
            string[] idSplit = id.Split('_');
            if (idSplit.Length != 2)
            {
                isValid = false;
            }

            // must start with 'lang'
            else if (!idSplit[0].ToLower().Equals("lang"))
            {
                isValid = false;
            }

            else if (langType.Equals("baseLang"))
            {
                // 2nd section must be letters
                if (!Utility_Methods.CheckStringValid("letters", idSplit[1]))
                {
                    isValid = false;
                }
            }

            else
            {
                // 1st character of 2nd section must be letter
                if (!Utility_Methods.CheckStringValid("letters", idSplit[1].Substring(0, 1)))
                {
                    isValid = false;
                }

                // last character of 2nd section must be number
                else if (!Utility_Methods.CheckStringValid("numbers", idSplit[1].Substring(idSplit[1].Length - 1, 1)))
                {
                    isValid = false;
                }
            }

            return(isValid);
        }
예제 #5
0
        /// <summary>
        /// Checks that a Place id is in the correct format
        /// </summary>
        /// <returns>bool indicating whether the id is valid</returns>
        /// <param name="id">The id to be validated</param>
        public static bool ValidatePlaceID(string id)
        {
            bool isValid = true;

            // ensure is 5 in length
            if (id.Length != 5)
            {
                isValid = false;
            }

            // ensure 1st is letter
            else if (!Utility_Methods.CheckStringValid("letters", id.Substring(0, 1)))
            {
                isValid = false;
            }

            // ensure ends in 2 numbers
            else if (!Utility_Methods.CheckStringValid("numbers", id.Substring(3)))
            {
                isValid = false;
            }

            return(isValid);
        }