Skip to content

Commit

Permalink
fix: remove some validations for domain sets (#430)
Browse files Browse the repository at this point in the history
The validation of the maximum characters used by a domain set in
the dnsmasq configuration file is now handled on the backend.

NethServer/nethsecurity#877
  • Loading branch information
andre8244 authored Nov 8, 2024
1 parent 0037e05 commit 7c5ebf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ function runFieldValidators(
return validators.every((validator) => validator.valid)
}

function validateRecordsRequired() {
let totalChars = 0

function validateRecords() {
for (const record of records.value) {
if (!record) {
return { valid: false, errMessage: 'error.empty_domains' }
Expand All @@ -137,14 +135,6 @@ function validateRecordsRequired() {
if (!valid) {
return { valid: false, errMessage: 'error.invalid_domains' }
}
totalChars += record.length
}

if (totalChars >= 960) {
return {
valid: false,
errMessage: 'error.domains_total_chars_exceeded'
}
}
return { valid: true }
}
Expand Down Expand Up @@ -174,7 +164,7 @@ function validate() {
nameRef
],
// records
[[validateRecordsRequired()], 'ipaddr', recordRef]
[[validateRecords()], 'domain', recordRef]
]

// reset firstErrorRef for focus management
Expand Down Expand Up @@ -281,10 +271,10 @@ async function saveDomainSet() {
/>
<!-- records invalid message -->
<p
v-if="errorBag.getFirstI18nKeyFor('ipaddr')"
v-if="errorBag.getFirstI18nKeyFor('domain')"
:class="'mt-2 text-sm text-rose-700 dark:text-rose-400'"
>
{{ t(errorBag.getFirstI18nKeyFor('ipaddr')) }}
{{ t(errorBag.getFirstI18nKeyFor('domain')) }}
</p>
<!-- save domain set error notification -->
<NeInlineNotification
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
"invalid_ipaddr": "One or more records are invalid",
"empty_domains": "One or more domains are empty",
"invalid_domains": "One or more domains are invalid",
"domains_total_chars_exceeded": "Total characters of all domains must not exceed 960. Please remove some domains or create a new domain set.",
"total_chars_exceeded": "There are too many domains. Please remove some and include them in a new domain set.",
"cannot_delete_host_set": "Cannot delete host set",
"cannot_delete_domain_set": "Cannot delete domain set",
"cannot_retrieve_host_sets": "Cannot retrieve host sets",
Expand Down

0 comments on commit 7c5ebf6

Please sign in to comment.