Skip to content

Commit

Permalink
refactor: using requiredIf to validate radio input
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bedon committed May 30, 2024
1 parent b8bb684 commit 470fb58
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/pages/LoginAndRegister/RegisterSocial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

<script>
import { validationMixin } from 'vuelidate';
import { required } from 'vuelidate/lib/validators';
import { requiredIf } from 'vuelidate/lib/validators';
import logReadQueryError from '@/util/logReadQueryError';
import KvBaseInput from '@/components/Kv/KvBaseInput';
import ReCaptchaEnterprise from '@/components/Forms/ReCaptchaEnterprise';
Expand Down Expand Up @@ -209,7 +209,7 @@ export default {
fetchedLogoAltText: null,
fetchedLogoUrl: null,
enableCommsExperiment: false,
needsComms: true,
needsComms: false,
selectedComms: '',
enableRadioBtnExperiment: false,
};
Expand Down Expand Up @@ -262,12 +262,10 @@ export default {
checked: val => val,
};
}
if (this.needsComms) {
validations.selectedComms = {
required,
checked: val => val !== '',
};
}
validations.selectedComms = {
required: requiredIf(() => this.needsComms),
};
return validations;
},
created() {
Expand Down Expand Up @@ -303,7 +301,6 @@ export default {
}
if (this.$route.query.passwordless) {
this.passwordless = true;
this.needsComms = false;
}
// Support legacy behavior of this page, which was to show the terms checkbox only
if (!this.$route.query.terms
Expand Down Expand Up @@ -334,10 +331,7 @@ export default {
if (version === 'c') {
this.enableRadioBtnExperiment = true;
this.newAcctTerms = true;
}
if (version !== 'c') {
this.needsComms = false;
this.needsComms = true;
}
}
},
Expand Down

0 comments on commit 470fb58

Please sign in to comment.