@@ -281,17 +281,6 @@ export default Component.extend(FormMixin, {
281
281
]
282
282
} ;
283
283
284
- const websiteValidation = {
285
- optional : true ,
286
- rules : [
287
- {
288
- type : 'regExp' ,
289
- value : compulsoryProtocolValidUrlPattern ,
290
- prompt : this . l10n . t ( 'Please enter a valid URL.' )
291
- }
292
- ]
293
- } ;
294
-
295
284
const websiteRequiredValidation = {
296
285
rules : [
297
286
{
@@ -306,16 +295,6 @@ export default Component.extend(FormMixin, {
306
295
]
307
296
} ;
308
297
309
- const blogValidation = {
310
- optional : true ,
311
- rules : [
312
- {
313
- type : 'regExp' ,
314
- value : compulsoryProtocolValidUrlPattern ,
315
- prompt : this . l10n . t ( 'Please enter a valid URL.' )
316
- }
317
- ]
318
- } ;
319
298
320
299
const blogRequiredValidation = {
321
300
rules : [
@@ -331,16 +310,6 @@ export default Component.extend(FormMixin, {
331
310
]
332
311
} ;
333
312
334
- const twitterValidation = {
335
- optional : true ,
336
- rules : [
337
- {
338
- type : 'regExp' ,
339
- value : validTwitterProfileUrlPattern ,
340
- prompt : this . l10n . t ( 'Please enter a valid Twitter profile URL.' )
341
- }
342
- ]
343
- } ;
344
313
345
314
const twitterRequiredValidation = {
346
315
rules : [
@@ -356,16 +325,6 @@ export default Component.extend(FormMixin, {
356
325
]
357
326
} ;
358
327
359
- const facebookValidation = {
360
- optional : true ,
361
- rules : [
362
- {
363
- type : 'regExp' ,
364
- value : validFacebookProfileUrlPattern ,
365
- prompt : this . l10n . t ( 'Please enter a valid Facebook account URL.' )
366
- }
367
- ]
368
- } ;
369
328
370
329
const facebookRequiredValidation = {
371
330
rules : [
@@ -381,17 +340,6 @@ export default Component.extend(FormMixin, {
381
340
]
382
341
} ;
383
342
384
- const githubValidation = {
385
- optional : true ,
386
- rules : [
387
- {
388
- type : 'regExp' ,
389
- value : validGithubProfileUrlPattern ,
390
- prompt : this . l10n . t ( 'Please enter a valid GitHub profile URL.' )
391
- }
392
- ]
393
- } ;
394
-
395
343
const githubRequiredValidation = {
396
344
rules : [
397
345
{
@@ -406,17 +354,6 @@ export default Component.extend(FormMixin, {
406
354
]
407
355
} ;
408
356
409
- const instagramValidation = {
410
- optional : true ,
411
- rules : [
412
- {
413
- type : 'regExp' ,
414
- value : validInstagramProfileUrlPattern ,
415
- prompt : this . l10n . t ( 'Please enter a valid Instagram account URL.' )
416
- }
417
- ]
418
- } ;
419
-
420
357
const instagramRequiredValidation = {
421
358
rules : [
422
359
{
@@ -431,16 +368,6 @@ export default Component.extend(FormMixin, {
431
368
]
432
369
} ;
433
370
434
- const linkedinValidation = {
435
- optional : true ,
436
- rules : [
437
- {
438
- type : 'regExp' ,
439
- value : validLinkedinProfileUrlPattern ,
440
- prompt : this . l10n . t ( 'Please enter a valid Linkedin account URL.' )
441
- }
442
- ]
443
- } ;
444
371
445
372
const linkedinRequiredValidation = {
446
373
rules : [
@@ -459,7 +386,7 @@ export default Component.extend(FormMixin, {
459
386
const isConsentFormFieldValidation = {
460
387
rules : [
461
388
{
462
- type : 'empty ' ,
389
+ type : 'checkbox ' ,
463
390
prompt : this . l10n . t ( 'Please enter Code of conduct consent.' )
464
391
}
465
392
]
@@ -560,63 +487,81 @@ export default Component.extend(FormMixin, {
560
487
}
561
488
}
562
489
} ;
563
- this . holders . forEach ( ( value , index ) => {
564
- validationRules . fields [ `firstname_required_${ index } ` ] = firstNameValidation ;
565
- validationRules . fields [ `lastname_required_${ index } ` ] = lastNameValidation ;
566
- validationRules . fields [ `email_required_${ index } ` ] = emailValidation ;
567
- validationRules . fields [ `gender_required_${ index } ` ] = genderValidation ;
568
- validationRules . fields [ `ageGroup_required_${ index } ` ] = ageGroupValidation ;
569
- validationRules . fields [ `address_required_${ index } ` ] = addressValidation ;
570
- validationRules . fields [ `acceptReceiveEmails_required_${ index } ` ] = acceptReceiveEmailsValidation ;
571
- validationRules . fields [ `acceptVideoRecording_required_${ index } ` ] = acceptVideoRecordingValidation ;
572
- validationRules . fields [ `acceptShareDetails_required_${ index } ` ] = acceptShareDetailsValidation ;
573
- validationRules . fields [ `city_required_${ index } ` ] = cityValidation ;
574
- validationRules . fields [ `state_required_${ index } ` ] = stateValidation ;
575
- validationRules . fields [ `country_required_${ index } ` ] = countryValidation ;
576
- validationRules . fields [ `jobTitle_required_${ index } ` ] = jobTitleValidation ;
577
- validationRules . fields [ `phone_required_${ index } ` ] = phoneValidation ;
578
- validationRules . fields [ `taxBusinessInfo_required_${ index } ` ] = taxBusinessInfoValidation ;
579
- validationRules . fields [ `billingAddress_required_${ index } ` ] = billingAddressValidation ;
580
- validationRules . fields [ `homeAddress_required_${ index } ` ] = homeAddressValidation ;
581
- validationRules . fields [ `homeWiki_required_${ index } ` ] = homeWikiValidation ;
582
- validationRules . fields [ `wikiScholarship_required_${ index } ` ] = wikiScholarshipValidation ;
583
- validationRules . fields [ `shippingAddress_required_${ index } ` ] = shippingAddressValidation ;
584
- validationRules . fields [ `company_required_${ index } ` ] = companyValidation ;
585
- validationRules . fields [ `workAddress_required_${ index } ` ] = workAddressValidation ;
586
- validationRules . fields [ `workPhone_required_${ index } ` ] = workPhoneValidation ;
587
- validationRules . fields [ `website_${ index } ` ] = websiteValidation ;
588
- validationRules . fields [ `website_required_${ index } ` ] = websiteRequiredValidation ;
589
- validationRules . fields [ `blog_${ index } ` ] = blogValidation ;
590
- validationRules . fields [ `blog_required_${ index } ` ] = blogRequiredValidation ;
591
- validationRules . fields [ `twitter_${ index } ` ] = twitterValidation ;
592
- validationRules . fields [ `twitter_required_${ index } ` ] = twitterRequiredValidation ;
593
- validationRules . fields [ `facebook_${ index } ` ] = facebookValidation ;
594
- validationRules . fields [ `facebook_required_${ index } ` ] = facebookRequiredValidation ;
595
- validationRules . fields [ `github_${ index } ` ] = githubValidation ;
596
- validationRules . fields [ `github_required_${ index } ` ] = githubRequiredValidation ;
597
- validationRules . fields [ `instagram_${ index } ` ] = instagramValidation ;
598
- validationRules . fields [ `instagram_required_${ index } ` ] = instagramRequiredValidation ;
599
- validationRules . fields [ `linkedin_${ index } ` ] = linkedinValidation ;
600
- validationRules . fields [ `linkedin_required_${ index } ` ] = linkedinRequiredValidation ;
601
- validationRules . fields [ `native_language_required_${ index } ` ] = nativeLanguageValidation ;
602
- validationRules . fields [ `fluent_language_required_${ index } ` ] = fluentLanguageValidation ;
603
- validationRules . fields [ `is_consent_form_field_required_${ index } ` ] = isConsentFormFieldValidation ;
604
- validationRules . fields [ `is_consent_of_refund_policy_required_${ index } ` ] = isConsentOfRefundPolicyValidation ;
605
- this . allFields . attendee . filter ( field => field . isComplex && field . isRequired ) . forEach ( field => {
606
- validationRules . fields [ `${ field . fieldIdentifier } _required_${ index } ` ] = {
607
- rules : [
608
- {
609
- type : 'empty' ,
610
- prompt : this . l10n . t ( 'Please enter {{field}}.' , { field : field . name } )
611
- }
612
- ]
613
- } ;
614
- } ) ;
615
-
490
+ const validationMap = {
491
+ firstname : firstNameValidation ,
492
+ lastname : lastNameValidation ,
493
+ email : emailValidation ,
494
+ gender : genderValidation ,
495
+ ageGroups : ageGroupValidation ,
496
+ address : addressValidation ,
497
+ acceptReceiveEmails : acceptReceiveEmailsValidation ,
498
+ acceptVideoRecording : acceptVideoRecordingValidation ,
499
+ acceptShareDetails : acceptShareDetailsValidation ,
500
+ city : cityValidation ,
501
+ state : stateValidation ,
502
+ country : countryValidation ,
503
+ jobTitle : jobTitleValidation ,
504
+ phone : phoneValidation ,
505
+ taxBusinessInfo : taxBusinessInfoValidation ,
506
+ billingAddress : billingAddressValidation ,
507
+ homeAddress : homeAddressValidation ,
508
+ homeWiki : homeWikiValidation ,
509
+ wikiScholarship : wikiScholarshipValidation ,
510
+ shippingAddress : shippingAddressValidation ,
511
+ company : companyValidation ,
512
+ workAddress : workAddressValidation ,
513
+ workPhone : workPhoneValidation ,
514
+ website : websiteRequiredValidation ,
515
+ blog : blogRequiredValidation ,
516
+ twitter : twitterRequiredValidation ,
517
+ facebook : facebookRequiredValidation ,
518
+ github : githubRequiredValidation ,
519
+ instagram : instagramRequiredValidation ,
520
+ linkedin : linkedinRequiredValidation ,
521
+ native_language : nativeLanguageValidation ,
522
+ fluent_language : fluentLanguageValidation ,
523
+ is_consent_form_field : isConsentFormFieldValidation ,
524
+ is_consent_of_refund_policy : isConsentOfRefundPolicyValidation
525
+
526
+ } ;
527
+ this . allFields . attendee . forEach ( ( field , index ) => {
528
+ const { fieldIdentifier } = field ;
529
+ const validationRuleKey = `${ fieldIdentifier } _required_${ index } ` ;
530
+ if ( validationMap [ fieldIdentifier ] ) {
531
+ validationRules . fields [ validationRuleKey ] = validationMap [ fieldIdentifier ] ;
532
+ } else {
533
+ if ( field . type === 'checkbox' ) {
534
+ validationRules . fields [ `${ field . fieldIdentifier } _required_${ index } ` ] = {
535
+ rules : [
536
+ {
537
+ type : 'checkbox' ,
538
+ prompt : this . l10n . t ( 'Please select your {{field}}.' , { field : field . name } )
539
+ }
540
+ ]
541
+ } ;
542
+ } else if ( field . type === 'boolean' ) {
543
+ validationRules . fields [ `${ field . fieldIdentifier } _required_${ index } ` ] = {
544
+ rules : [
545
+ {
546
+ type : 'checked' ,
547
+ prompt : this . l10n . t ( 'Please choosen your {{field}}.' , { field : field . name } )
548
+ }
549
+ ]
550
+ } ;
551
+ } else {
552
+ validationRules . fields [ `${ field . fieldIdentifier } _required_${ index } ` ] = {
553
+ rules : [
554
+ {
555
+ type : 'empty' ,
556
+ prompt : this . l10n . t ( 'Please enter your {{field}}.' , { field : field . name } )
557
+ }
558
+ ]
559
+ } ;
560
+ }
561
+ }
616
562
} ) ;
617
563
return validationRules ;
618
564
} ,
619
-
620
565
allFields : computed ( 'fields' , function ( ) {
621
566
const requiredFixed = this . fields . toArray ( ) ?. filter ( field => field . isFixed ) ;
622
567
const current_locale = this . cookies . read ( 'current_locale' ) ;
0 commit comments