Skip to content

Instantly share code, notes, and snippets.

@youngshook
Last active January 21, 2019 10:05
Show Gist options
  • Save youngshook/239aa66643a36c7450ea690f311bf7d8 to your computer and use it in GitHub Desktop.
Save youngshook/239aa66643a36c7450ea690f311bf7d8 to your computer and use it in GitHub Desktop.
// check the name is between 4 and 16 characters
if !(4...16 ~= name.characters.count) {
return false
}
// check that name doesn't contain whitespace or newline characters
let range = name.rangeOfCharacterFromSet(.whitespaceAndNewlineCharacterSet())
if let range = range where range.startIndex != range.endIndex {
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment