rr validation

This commit is contained in:
Sense T 2024-04-11 12:10:57 +08:00
parent 58c66fc3a8
commit 2ab1b0bf1b
3 changed files with 57 additions and 2 deletions

View File

@ -186,6 +186,30 @@ const rules = {
return new Error(t('common.mandatory'))
}
if (props.record.name.includes(' ')) {
invalidData.value &= ~validationFlags.name
return new Error(t('records.errors.hasSpace'))
}
if (props.record.name.startsWith('.') || props.record.name.endsWith('.')) {
invalidData.value &= ~validationFlags.name
return new Error(t('records.errors.badName.dotAndMinus'))
}
if (props.record.name.startsWith('-') || props.record.name.endsWith('-')) {
invalidData.value &= ~validationFlags.name
return new Error(t('records.errors.badName.dotAndMinus'))
}
if (props.record.name.includes('..')) {
invalidData.value &= ~validationFlags.name
return new Error(t('records.errors.badName.doubleDots'))
}
if (props.record.name.split('.').filter(e => e.length > 63).length > 0) {
invalidData.value &= ~validationFlags.name
return new Error(t('records.errors.badName.longerThan63'))
}
return true
}
},
@ -216,6 +240,10 @@ const rules = {
return new Error(t('common.mandatory'))
}
if (r.host.includes(' ')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.hasSpace'))
}
if (!r.host.endsWith('.')) {
invalidData.value &= ~validationFlags.content
@ -268,6 +296,11 @@ const rules = {
return new Error(t('common.mandatory'))
}
if (r.host.includes(' ')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.hasSpace'))
}
if (!r.host.endsWith('.')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.endWithDot'))
@ -288,6 +321,11 @@ const rules = {
return new Error(t('common.mandatory'))
}
if (r.target.includes(' ')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.hasSpace'))
}
if (!r.target.endsWith('.')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.endWithDot'))
@ -308,6 +346,11 @@ const rules = {
return new Error(t('common.mandatory'))
}
if (r.tag.includes(' ')) {
invalidData.value &= ~validationFlags.content
return new Error(t('records.errors.hasSpace'))
}
return true
}
}

View File

@ -58,7 +58,7 @@ export default {
},
records: {
'_': 'Record',
name: 'Record Name',
name: 'Resource Record',
recordType: 'Type',
content: 'Record',
search: 'Search...',
@ -83,8 +83,14 @@ export default {
errors: {
endWithDot: 'should end with a dot',
hasSpace: 'shoule have no space',
badIPv4: 'invalid IPv4 address',
badIPv6: 'invalid IPv6 address',
badName: {
dotAndMinus: 'should not start or end with "." "-"',
doubleDots: 'should have no contianus "."',
logerThan63: 'should not longer than 63 characters splited by "."'
}
}
}
}

View File

@ -58,7 +58,7 @@ export default {
},
records: {
'_': '记录',
name: '记录',
name: '资源记录',
recordType: '类型',
content: '记录值',
search: '搜索...',
@ -83,8 +83,14 @@ export default {
errors: {
endWithDot: '应当以 . 结尾',
hasSpace: '不能有空格',
badIPv4: '不是有效的 IPv4 地址',
badIPv6: '不是有效的 IPv6 地址',
badName: {
dotAndMinus: '资源记录不能以 "."、"-" 开头或结尾',
doubleDots: '资源记录不能有连续的 "."',
logerThan63: '资源记录以 "." 分割的每个字符串长度不能超过63字符'
}
}
}
}