String Validators

  • + 1 comment

    This will sometimes be more efficient than a solution that applies one check to each character in the string until it finds a match, then moves onto the next check. But sometimes it will be much more inefficient. This is because you apply all the checks to all the characters in the string, every time, even if checks have already been passed. So, if a string is 1000 characters long and all 5 checks are passec in the first few characters, you still go on to apply 5000 checks to 1000 characters. In contrast, a solution that uses the any function to check the string for each check in sequence will apply no more than 15 checks to 5 characters.