forked from MapComplete/MapComplete
		
	More refactoring
This commit is contained in:
		
							parent
							
								
									5d0fe31c41
								
							
						
					
					
						commit
						41e6a2c760
					
				
					 147 changed files with 1540 additions and 1797 deletions
				
			
		
							
								
								
									
										27
									
								
								UI/InputElement/Validators/FloatValidator.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								UI/InputElement/Validators/FloatValidator.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| import { Translation } from "../../i18n/Translation" | ||||
| import Translations from "../../i18n/Translations" | ||||
| import { Validator } from "../ValidatedTextField" | ||||
| 
 | ||||
| export default class FloatValidator extends Validator { | ||||
|     inputmode = "decimal" | ||||
| 
 | ||||
|     constructor(name?: string, explanation?: string) { | ||||
|         super(name ?? "float", explanation ?? "A decimal number", "decimal") | ||||
|     } | ||||
| 
 | ||||
|     isValid(str) { | ||||
|         return !isNaN(Number(str)) && !str.endsWith(".") && !str.endsWith(",") | ||||
|     } | ||||
| 
 | ||||
|     reformat(str): string { | ||||
|         return "" + Number(str) | ||||
|     } | ||||
| 
 | ||||
|     getFeedback(s: string): Translation { | ||||
|         if (isNaN(Number(s))) { | ||||
|             return Translations.t.validation.nat.notANumber | ||||
|         } | ||||
| 
 | ||||
|         return undefined | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue