Re-engineer UI in TypeScript (#89)
* Re-engineer UI in TypeScript * Switch to named imports where possible * Restructure file system layout * Update depencencies * Update README.md * Change explicit colors for better support for dark theme
This commit is contained in:
		
							
								
								
									
										4
									
								
								interface/src/validators/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								interface/src/validators/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
export { default as isHostname } from './isHostname';
 | 
			
		||||
export { default as isIP } from './isIP';
 | 
			
		||||
export { default as optional } from './optional';
 | 
			
		||||
export { default as or } from './or';
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
const hostnameLengthRegex = /^.{0,32}$/
 | 
			
		||||
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) {
 | 
			
		||||
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]?)$/
 | 
			
		||||
 | 
			
		||||
export default function isIp(ipAddress) {
 | 
			
		||||
export default function isIp(ipAddress: string) {
 | 
			
		||||
  return ipAddressRegexp.test(ipAddress);
 | 
			
		||||
}
 | 
			
		||||
@@ -1 +0,0 @@
 | 
			
		||||
export default validator => value => !value || validator(value);
 | 
			
		||||
							
								
								
									
										1
									
								
								interface/src/validators/optional.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								interface/src/validators/optional.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
export default (validator: (value: any) => boolean) => (value: any) => !value || validator(value);
 | 
			
		||||
@@ -1 +0,0 @@
 | 
			
		||||
export default (validator1, validator2) => value => validator1(value) || validator2(value);
 | 
			
		||||
							
								
								
									
										3
									
								
								interface/src/validators/or.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								interface/src/validators/or.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
export default (validator1: (value: any) => boolean, validator2: (value: any) => boolean) => {
 | 
			
		||||
    return (value: any) => validator1(value) || validator2(value);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user