forked from p15670423/monkey
Added hostname's to IP range validation
This commit is contained in:
parent
c1717d01a5
commit
cc78076d32
|
@ -1,5 +1,6 @@
|
||||||
const ipRegex = '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
const ipRegex = '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
||||||
const cidrNotationRegex = '([0-9]|1[0-9]|2[0-9]|3[0-2])'
|
const cidrNotationRegex = '([0-9]|1[0-9]|2[0-9]|3[0-2])'
|
||||||
|
const hostnameRegex = '^([A-Za-z0-9]*[A-Za-z]+[A-Za-z0-9]*.?)*([A-Za-z0-9]*[A-Za-z]+[A-Za-z0-9]*)$'
|
||||||
|
|
||||||
export const formValidationFormats = {
|
export const formValidationFormats = {
|
||||||
'ip-range': buildIpRangeRegex(),
|
'ip-range': buildIpRangeRegex(),
|
||||||
|
@ -10,7 +11,8 @@ function buildIpRangeRegex(){
|
||||||
return new RegExp([
|
return new RegExp([
|
||||||
'^'+ipRegex+'$|', // Single IP
|
'^'+ipRegex+'$|', // Single IP
|
||||||
'^'+ipRegex+'-'+ipRegex+'$|', // IP range IP-IP
|
'^'+ipRegex+'-'+ipRegex+'$|', // IP range IP-IP
|
||||||
'^'+ipRegex+'/'+cidrNotationRegex+'$' // IP range with cidr notation: IP/cidr
|
'^'+ipRegex+'/'+cidrNotationRegex+'$|', // IP range with cidr notation: IP/cidr
|
||||||
|
hostnameRegex, // IP range with cidr notation: IP/cidr
|
||||||
].join(''))
|
].join(''))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue