Validator for username

I will be inputtting a list of banned / reserved words in to an array, and I need to make sure that a user cannot choose one of those words as their username.

How can this be done?

Use CRangeValidator and set $not to true (property was added in 1.1.5).

Nice one bro. How can I ensure that the match is case-insensitive? There does not seem to be an option for that.

If you need that, you may create your own validator, or use CRegularExpression validator with not property. Something like this maybe:

'username', 'match', 'not' => true, 'pattern' => '/^(' . implode($disallowedUsernames, '|') . ')$/i'

That works perfect bro. BTW do you think it would be a good idea to add a ‘case insensitive search’ option to the range validator?