def METHOD_NAME(self, password_rules):
    secret_type = self.initial_data['secret_type']
    if secret_type != SecretType.PASSWORD:
        return password_rules
    if self.initial_data.get('secret_strategy') == SecretStrategy.custom:
        return password_rules
    length = password_rules.get('length')
    symbol_set = password_rules.get('symbol_set', '')
    try:
        length = int(length)
    except Exception as e:
        logger.error(e)
        msg = _("* Please enter the correct password length")
        raise serializers.ValidationError(msg)
    if length < 6 or length > 30:
        msg = _('* Password length range 6-30 bits')
        raise serializers.ValidationError(msg)
    if not isinstance(symbol_set, str):
        symbol_set = str(symbol_set)
    password_rules = {'length': length, 'symbol_set': ''.join(symbol_set)}
    return password_rules