feat(json-to-csv) add example default value
This commit is contained in:
		
							parent
							
								
									f836666417
								
							
						
					
					
						commit
						e2498d6f90
					
				| @ -4,6 +4,8 @@ import { convertArrayToCsv } from './json-to-csv.service'; | |||||||
| import type { UseValidationRule } from '@/composable/validation'; | import type { UseValidationRule } from '@/composable/validation'; | ||||||
| import { withDefaultOnError } from '@/utils/defaults'; | import { withDefaultOnError } from '@/utils/defaults'; | ||||||
| 
 | 
 | ||||||
|  | const defaultValue = '[\n   {\n      "Age": 18,\n      "Country": "Germany",\n      "Gender": "Male",\n      "Purchased": "N",\n      "Salary": 20000\n   },\n   {\n      "Age": 19,\n      "Country": "France",\n      "Gender": "Female",\n      "Purchased": "N",\n      "Salary": 22000\n   },\n   {\n      "Age": 20,\n      "Country": "England",\n      "Gender": "Female",\n      "Purchased": "N",\n      "Salary": 24000\n   }\n]'; | ||||||
|  | 
 | ||||||
| function transformer(value: string) { | function transformer(value: string) { | ||||||
|   return withDefaultOnError(() => { |   return withDefaultOnError(() => { | ||||||
|     if (value === '') { |     if (value === '') { | ||||||
| @ -24,6 +26,7 @@ const rules: UseValidationRule<string>[] = [ | |||||||
| <template> | <template> | ||||||
|   <format-transformer |   <format-transformer | ||||||
|     input-label="Your raw JSON" |     input-label="Your raw JSON" | ||||||
|  |     :input-default="defaultValue" | ||||||
|     input-placeholder="Paste your raw JSON here..." |     input-placeholder="Paste your raw JSON here..." | ||||||
|     output-label="CSV version of your JSON" |     output-label="CSV version of your JSON" | ||||||
|     :input-validation-rules="rules" |     :input-validation-rules="rules" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user