protected function enrichRulesNew(
        array $customRules,
        array $generatedRules,
        $replace,
        array $excludeKeys,
        array $keepDefaultKeys,
        array $generatedRulesMap
    ) {
        // so use them as a starting point.
        // If custom rules are configured, they should not overwritten by form field rules,
        $result = $customRules;

        // Include any generated rules explicitly marked for inclusion.
        foreach ($keepDefaultKeys as $key) {
            if ( ! array_key_exists($key, $generatedRules)) {
                continue;
            }

            $result[ $key ] = $generatedRules[ $key ];
        }


        // If the generated rules are explicitly replaced default rules, we don't have to merge them.
        // Otherwise, append any form field defined rule that is
        // not yet included and not marked for exclusion.
        if ( ! $replace) {

            foreach ($generatedRulesMap as $fieldKey => $ruleKeys) {

                // The field key or any of its nested child rules keys may be disabled.
                // If the field key itself is excluded, find the mapped keys for that
                // field and exclude any of them.

                // So skip any set of rules belonging to a field whose key has
                // been excluded (as a rule key).
                if (in_array($fieldKey, $excludeKeys)) {
                    continue;
                }

                foreach ($ruleKeys as $key) {

                    // Skip if ..
                    if (
                        // .. the key is already included, or marked for exclusion
                            in_array($key, $excludeKeys)
                        ||  in_array($key, $keepDefaultKeys)
                        // .. the result array already has an entry for the key
                        ||  array_key_exists($key, $result)
                        // .. no generated rule exists for the key (safeguard)
                        ||  ! array_key_exists($key, $generatedRules)
                    ) {
                        continue;
                    }

                    $result[ $key ] = $generatedRules[ $key ];
                }
            }
        }

        $result = $this->getRuleMerger()->convertRequiredForTranslatedFields($result);

        return $this->castValidationRulesToArray($result);
    }