class ActiveLdap::Schema::Syntaxes::BitString

def normalize_value(value)

def normalize_value(value)
  if value.is_a?(String) and /\A[01]*\z/ =~ value
    "'#{value}'B"
  else
    value
  end
end

def type_cast(value)

def type_cast(value)
  return nil if value.nil?
  if /\A'([01]*)'B\z/ =~ value.to_s
    $1
  else
    value
  end
end

def validate_normalized_value(value, original_value)

def validate_normalized_value(value, original_value)
  if /\A'/ !~ value
    return _("%s doesn't have the first \"'\"") % original_value.inspect
  end
  if /'B\z/ !~ value
    return _("%s doesn't have the last \"'B\"") % original_value.inspect
  end
  if /([^01])/ =~ value[1..-3]
    return _("%s has invalid character '%s'") % [value.inspect, $1]
  end
  nil
end