Skip to content

Commit

Permalink
fix(mwan): fixing validation on default rule (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile authored Nov 12, 2024
1 parent 6974a19 commit 767d4a1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/composables/useRuleForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,23 @@ export function useRuleForm(policies: Ref<Policy[]>, rule?: Ref<Rule | undefined

function isValid() {
validationErrors.value.clear()
let validationCheck = validateRequired(name.value)
let validationCheck = validateRequired(policy.value)
if (!validationCheck.valid) {
validationErrors.value.set('name', String(validationCheck.errMessage))
validationErrors.value.set('policy', String(validationCheck.errMessage))
}
validationCheck = validateRequired(policy.value)
if (!validationCheck.valid) {
validationErrors.value.set('policy', String(validationCheck.errMessage))
}
const { valid, errMessage, i18Params } = validateUciName(name.value, 12)
if (!valid) {
validationErrors.value.set('name', t(errMessage as string, i18Params as any))
if (name.value != 'Default Rule') {
validationCheck = validateRequired(name.value)
if (!validationCheck.valid) {
validationErrors.value.set('name', String(validationCheck.errMessage))
}
const { valid, errMessage, i18Params } = validateUciName(name.value, 12)
if (!valid) {
validationErrors.value.set('name', t(errMessage as string, i18Params as any))
}
}
if (sourceAddress.value != '') {
validationCheck = validateIp4OrCidr(sourceAddress.value)
Expand Down

0 comments on commit 767d4a1

Please sign in to comment.