You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: comment_locking_validator.rb
    path of file: ./repos/open-build-service/src/api/app/models
    
    the code of the file until where you have to start completion: class CommentLockingValidator < ActiveModel::Validator
  def 
    
  def maintainer_or_unlocked(record)
    user = User.session
    policy = CommentPolicy.new(user, record)
    # Allow maintainers and admins, moderators and staff to create comments despite the lock
    return true if policy.maintainer? || user&.is_admin? || user&.is_moderator? || user&.is_staff?

    # Check if there is a lock, including the parents (project for package and bs_request for bs_request_action)
    !policy.locked?
  end