title: How to validate that username does not start with certain string?
body: <p>One of the variables in a User model is <code>username</code>. I would like to reserve usernames starting with "vondel" for something else. Therefore, I would like to make it invalid for a <code>username</code> to start with "vondel". How can I do this?</p>
  
  <p>Below is my attempt to set the validations on <code>username</code>. However, generating a <code>username</code> that starts with "vondel" is still possible and generates no error message. Is there a way to do this with a regular expression?</p>
  
  <pre><code>before_save :downcase_username        # Method that converts username to all downcase.
  VALID_USERNAME_REGEX = /\A[a-zA-Z0-9_-]+\z/i
  validates :username, presence: true,
                       length: { in: 6..15 },
                       format: { with: VALID_USERNAME_REGEX },
                       uniqueness: { case_sensitive: false }
  validate :vondel_not_allowed
  
  private 
    def vondel_not_allowed
      if username == "vondel*"
        errors.add(:username, "Username cannot start with 'vondel'")
      end
    end
  </code></pre>