Do not mark as duplicate, edit of this post has set it apart from the other possible duplicate post. I'm in the process of registering users into my application. It is essential that I disallow as many vulgar usernames as possible as they can be seen by everybody. What I have done thus far is:
- Collect proposed username from
UITextView
- Pull the list of disallowed words from my
Firebase
database
I am returning the snapshot
as its default return type, so, from here, I need to search said snapshot for any resemblance of the proposed username. How can I accomplish this? Here is some of the code I am using below:
func nameFilter(input : String)-> Bool{
var profanity : Bool = false
let dataRef = FIRDatabase.database().reference()
dataRef.child("Profanity").observeSingleEventOfType(.Value) { (snap: FIRDataSnapshot) in
if(snap.exists()){
if(snap.hasChild(input)){
print("profanity")
profanity = true
}else{
profanity = false
}
}else{
print("null")
}
}
return profanity
}
This didn't seem to work at all, so does anybody here have any ideas as to what I can try? This function always seems to return false no matter what I pass through it.