mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
eslint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export { default as isHostname } from './isHostname'
|
||||
export { default as isIP } from './isIP'
|
||||
export { default as optional } from './optional'
|
||||
export { default as or } from './or'
|
||||
export { default as isPath } from './isPath'
|
||||
export { default as isHostname } from './isHostname';
|
||||
export { default as isIP } from './isIP';
|
||||
export { default as optional } from './optional';
|
||||
export { default as or } from './or';
|
||||
export { default as isPath } from './isPath';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const hostnameLengthRegex = /^.{0,48}$/
|
||||
const hostnamePatternRegex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/
|
||||
const hostnameLengthRegex = /^.{0,48}$/;
|
||||
const hostnamePatternRegex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/;
|
||||
|
||||
export default function isHostname(hostname: string) {
|
||||
return (
|
||||
hostnameLengthRegex.test(hostname) && hostnamePatternRegex.test(hostname)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const ipAddressRegexp = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
|
||||
const ipAddressRegexp = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||||
|
||||
export default function isIp(ipAddress: string) {
|
||||
return ipAddressRegexp.test(ipAddress)
|
||||
return ipAddressRegexp.test(ipAddress);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const pathLengthRegex = /^[^.]{0,108}$/
|
||||
const pathPatternRegex = /^([a-zA-Z0-9_][a-zA-Z0-9/_-]*[a-zA-Z0-9_])$/
|
||||
const pathLengthRegex = /^[^.]{0,108}$/;
|
||||
const pathPatternRegex = /^([a-zA-Z0-9_][a-zA-Z0-9/_-]*[a-zA-Z0-9_])$/;
|
||||
|
||||
export default function isPath(path: string) {
|
||||
return pathLengthRegex.test(path) && pathPatternRegex.test(path)
|
||||
return pathLengthRegex.test(path) && pathPatternRegex.test(path);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const OPTIONAL = (validator: (value: any) => boolean) => (value: any) =>
|
||||
!value || validator(value)
|
||||
!value || validator(value);
|
||||
|
||||
export default OPTIONAL
|
||||
export default OPTIONAL;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const OR = (
|
||||
validator1: (value: any) => boolean,
|
||||
validator2: (value: any) => boolean,
|
||||
validator2: (value: any) => boolean
|
||||
) => {
|
||||
return (value: any) => validator1(value) || validator2(value)
|
||||
}
|
||||
return (value: any) => validator1(value) || validator2(value);
|
||||
};
|
||||
|
||||
export default OR
|
||||
export default OR;
|
||||
|
||||
Reference in New Issue
Block a user