/// <summary> /// Last name validation. /// </summary> /// <param name="lastName">The last name.</param> /// <returns></returns> /// <exception cref="UserRegistrationExceptions"> /// lastName should be min of 3 char /// or /// lastName should Not be Empty /// or /// lastName should not conatin any number /// or /// lastName should not contain the splCharacteres /// or /// lastName should Contain with uppercase /// </exception> public bool lastName_Validation(String lastName) { bool result = Regex.IsMatch(lastName, NAME_PATTERN); try { if (result == false) { if (lastName.Equals(string.Empty)) { throw new UserRegistrationExceptions(UserRegistrationExceptions.ExceptionType.ENTERED_EMPTY, "lastName should Not be Empty"); } if (lastName.Length < 3) { throw new UserRegistrationExceptions(UserRegistrationExceptions.ExceptionType.ENTERED_LESSTHAN_MINCHAR, "lastName should be min of 3 char"); } if (!char.IsUpper(lastName[0])) { throw new UserRegistrationExceptions(UserRegistrationExceptions.ExceptionType.ENTERED_LOWERCASE, "lastName should start with uppercase"); } if (lastName.Any(char.IsDigit)) { throw new UserRegistrationExceptions(UserRegistrationExceptions.ExceptionType.ENTERED_NUMBER, "lastName should not conatin any number"); } if (lastName.Any(char.IsLetterOrDigit)) { throw new UserRegistrationExceptions(UserRegistrationExceptions.ExceptionType.ENTERED_SPECIAL_CHARACTER, "lastName should not contain the splCharacteres"); } } return(result); }catch (UserRegistrationExceptions e) { throw e; } }
public bool IsUseCaseCreated(string nameOfCreatedTC) { String[] allText = new String[listOfCreatedTC.Count]; int i = 0; foreach (IWebElement element in listOfCreatedTC) { allText[i++] = element.Text; } return(allText.Any(nameOfCreatedTC.Contains)); }
/// <summary> /// Determs if the summary text/html is valid. A valid summary is any text containing atleast one letter. /// </summary> /// <param name="summary"></param> /// <returns></returns> public static bool IsValidSummaryForDocumentListVisualization(String summary) { String trimmedSummary = (summary == null ? String.Empty : summary).Trim(); String taglessSummary = ApisStringHelper.StripTags(trimmedSummary); bool isValidSummary = taglessSummary != null; isValidSummary &= !String.IsNullOrEmpty(taglessSummary.Trim()); isValidSummary &= taglessSummary.Any(Char.IsLetter); return(isValidSummary); }
public static string RemoveSign4VN(string str) { String ssss = str; if (!String.IsNullOrEmpty(ssss)) { ssss = ssss.Trim(); } else { return(""); } if (ssss.Any(p => VietnameseSigns_UnicodeToHop.Any(q => q.Any(x => x > 255 && x == p)))) { for (int i = 0; i < VietnameseSigns_UnicodeToHop.Length; i++) { for (int j = 0; j < VietnameseSigns_UnicodeToHop[i].Length; j++) { if (VietnameseSigns_UnicodeToHop[i][j] > 255) { ssss = ssss.Replace(VietnameseSigns_UnicodeToHop[i][j].ToString(), ""); } } } } if (ssss.Any(p => VietnameseSigns.Any(q => q.Any(x => x == p)))) { for (int i = 1; i < VietnameseSigns.Length; i++) { for (int j = 0; j < VietnameseSigns[i].Length; j++) { ssss = ssss.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]); } } } return(ssss); }
private void RegisterAction(object sender, RoutedEventArgs e) { String newEmail = RegisterEmailTextBox.Text; String newPassword = RegisterPasswordTextBox.Password; string[] usersData = File.ReadAllLines(@"Users login details.txt"); bool isRegisterAllowed = true; if (newPassword.Length >= 7 && newPassword.Any(char.IsUpper) && newPassword.Any(char.IsDigit)) { foreach (string line in usersData) { String[] userData = line.Split('|'); // email, password, publicKey, privateKey if (newEmail == userData[0]) { isRegisterAllowed = false; break; // TODO Textbox - This email already is in use } } if (isRegisterAllowed) { RSA newRsaKeys = new RSACryptoServiceProvider(2048); // Generate a new 2048 bit RSA key var newUser = new User(newEmail, UsersControler.GenerateSHA512String(newPassword), newRsaKeys.ToXmlString(false), newRsaKeys.ToXmlString(true)); var newTxtLine = newEmail + "|" + UsersControler.GenerateSHA512String(newPassword) + "|" + newRsaKeys.ToXmlString(false) + "|" + newRsaKeys.ToXmlString(true); File.AppendAllText(@"Users login details.txt", Environment.NewLine + newTxtLine); UsersControler.usersList.Add(newUser); UsersControler.currentUser = newUser; Close(); } } else { MessageBox.Show("Password is too weak, needs at lest one number, one great letter and 8 signs"); } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { String stringValue = value.ToString(); if (stringValue.Any(char.IsDigit) == false) { return(ValidationResult.Success); } } return(new ValidationResult("Name can't contain digits.")); }
private Int32 _linqCount(String J, String S) { if ((J == null) || (J.Length == 0)) { return(0); } if ((S == null) || (S.Length == 0)) { return(0); } return(S.Count(stone => J.Any(jewel => stone == jewel))); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { String stringValue = value.ToString(); if (stringValue.Any(char.IsLetter) == false) { return(ValidationResult.Success); } } return(new ValidationResult("Phone number can't contain letters.")); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { String stringValue = value.ToString(); if (stringValue.Any(char.IsDigit) == false) { return(ValidationResult.Success); } } return(new ValidationResult("Only letters please")); }
private void validatenow() { String nic = txtNIC.Text.ToString(); String position = dropdPos.Text.ToString(); String firstName = txtfName.Text.ToString(); String lastName = txtlName.Text.ToString(); //String birthday = datetimeBD.Text.ToString(); String addressNo = txtAddressNo.Text.ToString(); String addressStreet = txtAddressStreet.Text.ToString(); String addressCity = txtAddressCity.Text.ToString(); String teleNo = txtTele.Text.ToString(); String email = txtEmail.Text.ToString(); if (String.IsNullOrWhiteSpace(position) || position.Any(Char.IsDigit)) { MessageBox.Show("Employee's position cannot be digits"); dropdPos.Select(); } if (!ValidationClass.checkEmail(email)) { MessageBox.Show("Email is Invalid"); } if (!ValidationClass.checkFname(firstName)) { MessageBox.Show("First Name is Invalid"); } if (!ValidationClass.checkLname(lastName)) { MessageBox.Show("Last Name is Invalid"); } if (!ValidationClass.checkTele(teleNo)) { MessageBox.Show("Contact No is Invalid"); } if (!ValidationClass.checkNIC(nic)) { MessageBox.Show("Invalid format"); } if (photoBox == null) { MessageBox.Show("Insert a Photo"); } }
public static void ValidIPAddress(String str) { try { if (String.IsNullOrEmpty(str) || String.IsNullOrWhiteSpace(str)) { Console.WriteLine(Constants.NO); } else if (!str.Contains(".")) { Console.WriteLine(Constants.NO); } else if (!str.Any(a => Char.IsDigit(a))) { Console.WriteLine(Constants.NO); } else { if (str.Where(a => a == '.').Count() != 3) { Console.WriteLine(Constants.NO); } else { Int32[] arr = str.Split(new Char[] { '.' }, StringSplitOptions.RemoveEmptyEntries) .Select(a => Convert.ToInt32(a)) .ToArray <Int32>(); if (arr.Length < 4) { Console.WriteLine(Constants.NO); } else { if (arr.Any(g => g > 255 || g < 0)) { Console.WriteLine(Constants.NO); } else { Console.WriteLine(Constants.YES); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public static String anyWhiteSpace(String str) { if (isEmpty(str) == true) { return("String is empty"); } if (str.Any(Char.IsWhiteSpace) == true) { return("No whitespaces allowed"); } return(null); }
public static String isVarChar(String varchar) { if (isEmpty(varchar) == true) { return("String is empty"); } if (varchar.Any(Char.IsLetterOrDigit) == false) { return("Must contain letters or digits"); } return(null); }
internal virtual bool validWord(String word) { var vowels = word .Where(c => "aeiou".Contains(c)); bool inOrder = vowels.SequenceEqual(vowels.OrderBy(c => c)); if (inOrder && !(word.Any(Char.IsUpper)) && !(word.Any(Char.IsPunctuation)) && !(word.Any(Char.IsDigit))) { if (word.Length > 3) { if (vowels.Count() >= 2) { return(true); } } else if (vowels.Count() > 0) { return(true); } } return(false); }
public override void parseArgs(string[] args) { findText = loadString(args[0].Trim()); replaceText = loadString(args[1].Trim()); countType = loadString(args[2].Trim()); if (countType.Any(char.IsDigit)) { countRequirement = loadInt(countType); countIsNumber = true; } else { countIsNumber = false; } }
public override String ToString() { CultureInfo cultureInfo = LocalizationBase.CurrentCulture; String dateTime = MessageAdditions switch { MessageAdditions.CurrentDate => DateTime.Date.ToString(cultureInfo), MessageAdditions.CurrentTime => $"{DateTime.Hour}:{DateTime.Minute}:{DateTime.Second}", MessageAdditions.CurrentDateTime => DateTime.ToString(cultureInfo), _ => String.Empty }; return($"{dateTime}{(dateTime.Any() ? " " : String.Empty)}{(Data?.Any() == true ? String.Format(Message, Data) : Message)}"); } }
//filter words to remove long words, single char and words with number private static bool unAcceptedWords(String word) { if (word.Length <= 2 || word.Length > 10) { return(true); } if (word.Any(char.IsDigit)) { return(true); } if (word.Any(char.IsSymbol)) { return(true); } if (word.Any(char.IsControl)) { return(true); } if (word.Contains(".com") || word.Contains(".net") || word.Contains(".edu")) { return(true); } return(false); }
static bool invalidWord(String s) { if (!s.All(char.IsLetter)) { return(true); } if (s.Length == 0) { return(true); } if (s.Any(char.IsDigit)) { return(true); } return(false); }
public bool numericCheck(String text) { if (String.IsNullOrWhiteSpace(text)) { MessageBox.Show("Please enter a value"); } else if (!text.Any(c => char.IsDigit(c))) { MessageBox.Show("Only numbers are allowed"); } else { return(true); } return(false); }
public void AddDataMethod(String myString) { if (myString.StartsWith("/a")) { myString = myString.Replace("/a ", string.Empty); myString = myString.Replace(".", ","); myString = myString.Replace("\r\n", string.Empty); if (myString.Any(char.IsNumber)) { currentAngle.Text = myString; myString = ""; } else { currentAngle.Text = "0"; } } else if (myString.StartsWith("Exit application")) { if (connected) { connected = false; onlineStatus.Text = "OFFLINE"; onlineStatus.BackColor = Color.Red; connectButton.Text = "Connect"; sp.Close(); sp.Dispose(); myString = ""; MessageBox.Show("Verbindung wurde vom Client terminiert.", "BN Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } else { receivedTextBox.AppendText(myString); } }
public IActionResult GetImages() { // get the real path of wwwroot/imagesFolder var rootDir = this._env.WebRootPath; // the extensions allowed to show var filters = new String[] { ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".bmp", ".svg" }; // set the base url = "/" var baseUrl = "/"; var imgUrls = Directory.EnumerateFiles(rootDir, "*.*", SearchOption.AllDirectories) .Where(fileName => filters.Any(filter => fileName.EndsWith(filter))) .Select(fileName => Path.GetRelativePath(rootDir, fileName)) // get relative path .Select(fileName => Path.Combine(baseUrl, fileName)) // prepend the baseUrl .Select(fileName => fileName.Replace("\\", "/")) // replace "\" with "/" ; return(new JsonResult(imgUrls)); }
public bool Check_InPut(String input) { if (input.Length > 1) { for (int i = 0; i < input.Length; i++) { if (input.Contains(" ") == true || input[i].ToString() == "_" || input.Any(char.IsDigit) == true)//Input check { return(false); } } return(true); } else { return(false); } }
public bool validateStringInput(String arg) { if (arg.Contains(' ') || arg.Contains("'")) { return(false); } else if (arg.Length < 8 || arg.Length > 30) { return(false); } else if (!arg.Any(c => char.IsUpper(c))) { return(false); } else { return(true); } }
public static string Capitalize(this String value) { if (value == null) { return(null); } if (value.Length == 0) { return(value); } if (!value.Any(char.IsLetter)) { return(value); } return(string.Join(" ", value .Split(" ") .ToList() .Select(s => s.Length > 0 ? char.ToUpper(s[0]) + (s.Length > 1 ? s.Substring(1) : "") : s))); }
public static Boolean IsUpper(String tokenString) { if (tokenString.StartsWith("http://")) { return(false); } Regex rgx = new Regex(".*[a-zA-Z]+.*"); if (rgx.IsMatch(tokenString)) { return(false); } if (tokenString.Any(c => char.IsLower(c)) == false) { return(false); } return(true); }
public void TryLetter(String letter) { if (String.IsNullOrEmpty(letter)) { throw new HangmanException("TryLetter(string) expected a Letter of the English Alphabet. Got empty or null string"); } if (letter.Length > 1) { throw new HangmanException("TryLetter(string) expected a Letter of the English Alphabet. Got " + letter); } if (letter.Any(x => !char.IsLetter(x))) { throw new HangmanException("TryLetter(string) expected a Letter of the English Alphabet. Got " + letter); } if (!IsGameStarted) { throw new HangmanGameNotStartedException(); } _lastState = HangmanState.LetterTried; var c = letter.ToUpper(); if (GivenWord.Contains(c)) { if (!CorrectLetters.Contains(c)) { CorrectLetters.Add(c); FetchGameState(); OnAttempt?.Invoke(_lastGameState); } } else { if (!IncorrectLetters.Contains(c)) { IncorrectLetters.Add(c); FetchGameState(); OnAttempt?.Invoke(_lastGameState); } } CheckGameState(); }
public bool kieTraNhapDungMatKhau(String matKhau) { if (matKhau.Length > 8 || matKhau.Length < 4) { return(false); } char[] arr = matKhau.ToCharArray(); foreach (char i in arr) { if (Char.IsWhiteSpace(i)) { return(false); } } if (matKhau.Any(ch => !Char.IsLetterOrDigit(ch))) { return(false); } return(true); }
/// <summary> /// Returns any terminating punctuation. Otherwise, returns String.Empty /// </summary> /// <param name="word"></param> /// <returns></returns> private String SeparatePunctuation(String word, out String puncSubStr) { puncSubStr = String.Empty; // is there any punctuation? var anyPunc = word.Any(c => char.IsPunctuation(c)); if (anyPunc) { // isolate any leading/trailing punctuation var firstPunc = word.First(c => char.IsPunctuation(c)); // find the index of the punctuation var indexOfFirstPunc = word.IndexOf(firstPunc); // isolate the punctuation and anything after it puncSubStr = word.Substring(indexOfFirstPunc); // word = word.Substring(0, indexOfFirstPunc); } return(word); }
public bool kiemTraNhapDungTaiKhoan(String taiKhoan) { if (taiKhoan.Length > 20 || taiKhoan.Length < 5) { return(false); } char[] arr = taiKhoan.ToCharArray(); foreach (char i in arr) { if (Char.IsWhiteSpace(i)) { return(false); } } if (taiKhoan.Any(ch => !Char.IsLetterOrDigit(ch))) { return(false); } return(true); }
public static bool IsBase64String(String String) { if (string.IsNullOrEmpty(String)) { return(false); } else if (String.Any(c => !_base64Characters.Contains(c))) { return(false); } try { Convert.FromBase64String(String); return(true); } catch (FormatException) { return(false); } }
public static string LoadPrincipiaDllAndInitGoogleLogging() { if (loaded_principia_dll_) { return null; } bool is_32_bit = IntPtr.Size == 4; if (is_32_bit) { return "32-bit platforms are no longer supported; " + "use the 64-bit KSP executable."; } String[] possible_dll_paths = null; bool can_determine_cxx_installed; Func<bool> is_cxx_installed; string required_cxx_packages; switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: can_determine_cxx_installed = true; is_cxx_installed = () => IsVCRedistInstalled(is_32_bit); required_cxx_packages = "the Visual C++ Redistributable Packages for Visual Studio " + "2015 on " + (is_32_bit ? "x86" : "x64"); possible_dll_paths = new String[] {@"GameData\Principia\" + (is_32_bit ? "Win32" : "x64") + @"\principia.dll"}; break; // Both Mac and Linux report |PlatformID.Unix|, so we treat them together // (we probably don't actually encounter |PlatformID.MacOSX|. case PlatformID.Unix: case PlatformID.MacOSX: possible_dll_paths = new String[] { @"GameData/Principia/Linux64/principia.so", @"GameData/Principia/MacOS64/principia.so"}; can_determine_cxx_installed = false; is_cxx_installed = null; required_cxx_packages = "libc++ and libc++abi 3.5-2"; break; default: return "The operating system " + Environment.OSVersion + " is not supported at this time."; } if (!possible_dll_paths.Any(File.Exists)) { return "The principia DLL was not found at '" + String.Join("', '", possible_dll_paths) + "'."; } try { loaded_principia_dll_ = true; Log.InitGoogleLogging(); return null; } catch (Exception e) { UnityEngine.Debug.LogException(e); if (can_determine_cxx_installed && !is_cxx_installed()) { return "Dependencies, namely " + required_cxx_packages + ", were not found."; } else { return "An unknown error occurred; detected OS " + Environment.OSVersion + " " + (is_32_bit ? "32" : "64") + "-bit; tried loading dll at '" + String.Join("', '", possible_dll_paths) + "'. Note that " + required_cxx_packages + " are required."; } } }