fix(Cron Parser): handle more patterns
Just use validation of cronstrue package Fix #855
This commit is contained in:
		
							parent
							
								
									cb5b462e11
								
							
						
					
					
						commit
						f1044b3e2b
					
				| @ -1,12 +1,7 @@ | ||||
| <script setup lang="ts"> | ||||
| import cronstrue from 'cronstrue'; | ||||
| import { isValidCron } from 'cron-validator'; | ||||
| import { useStyleStore } from '@/stores/style.store'; | ||||
| 
 | ||||
| function isCronValid(v: string) { | ||||
|   return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true }); | ||||
| } | ||||
| 
 | ||||
| const styleStore = useStyleStore(); | ||||
| 
 | ||||
| const cron = ref('40 * * * *'); | ||||
| @ -17,6 +12,16 @@ const cronstrueConfig = reactive({ | ||||
|   throwExceptionOnParseError: true, | ||||
| }); | ||||
| 
 | ||||
| function isCronValid(v: string) { | ||||
|   try { | ||||
|     cronstrue.toString(v, cronstrueConfig); | ||||
|     return true; | ||||
|   } | ||||
|   catch (_) { | ||||
|     return false; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const helpers = [ | ||||
|   { | ||||
|     symbol: '*', | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user