예제 #1
0
        /// <summary>
        /// Méthode qui tente d'internationaliser un numéro de téléphone fourni au format 'France métropolitaine'
        /// </summary>
        /// <remarks>Fonctionne aussi pour les numéros de mobile</remarks>
        /// <param name="input">Numéro de téléphone en entrée</param>
        /// <param name="internationalizedPhone">Numéro de téléphone converti au format international</param>
        /// <returns>Vrai si la conversion a fonctionné</returns>
        public static bool TryInternationalizeFrenchPhone(string input, out string internationalizedPhone)
        {
            // Nettoyage de la chaine de caractère
            string cleanInput = CleanPhone(input).Trim();

            // On teste si l'entrée n'est pas déjà au format internationnal
            if (RegexHelper.IsMatch(cleanInput, RegexHelper.RegexType.FrenchInternationalPhone))
            {
                internationalizedPhone = cleanInput;
                return(true);
            }

            if (RegexHelper.IsMatch(cleanInput, RegexHelper.RegexType.FrenchPhone))
            {
                // L'entrée est au format "France métropolitaine", on va le convertir
                // En enlevant le premier 0.
                cleanInput = cleanInput.Substring(1);
                cleanInput = string.Format("+33{0}", cleanInput);

                if (RegexHelper.IsMatch(cleanInput, RegexHelper.RegexType.FrenchInternationalPhone))
                {
                    internationalizedPhone = cleanInput;
                    return(true);
                }
            }

            internationalizedPhone = null;
            return(false);
        }
예제 #2
0
 /// <summary>
 /// Retourne un booléen qui indique si le numéro de téléphone est au format Français.
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static bool IsFrenchPhone(string input)
 {
     return(RegexHelper.IsMatch(input, RegexHelper.RegexType.FrenchPhone));
 }
예제 #3
0
 public static bool IsInteger(string value)
 {
     return(RegexHelper.IsMatch(value, RegexHelper.RegexType.IsInteger));
 }
예제 #4
0
 /// <summary>
 /// retourne un booléen qui indique si le numéro de téléphone est au format mobile international Français (+33)
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static bool IsFrenchInternationalMobilePhone(string input)
 {
     return(RegexHelper.IsMatch(input, RegexHelper.RegexType.FrenchInternationalMobilePhone));
 }
예제 #5
0
 /// <summary>
 /// Vérifie si une valeur est numérique
 /// </summary>
 /// <param name="value">Valeur à vérifier</param>
 /// <returns>Vrai si la valeur est numérique</returns>
 public static bool IsNumeric(object value)
 {
     return(RegexHelper.IsMatch(value.ToString(), RegexHelper.RegexType.IsNumeric));
 }