diff --git a/src/components/MissionAppDns.vue b/src/components/MissionAppDns.vue
index b1affd4f2aa2e78512d7ab284009b770b03d3ab2..ca9ed9926798c2ee2af4f1a6f9e2954397cb3173 100644
--- a/src/components/MissionAppDns.vue
+++ b/src/components/MissionAppDns.vue
@@ -7,29 +7,26 @@
class="mb-8"
label="Dns Credential Name"
v-model="dns.credentialName"
- hint="* Required"
+ :hint="hint"
persistent-hint
- required
- :rules="[inputRules.required]"
+ :required="isRequired"
/>
@@ -48,6 +45,18 @@ export default {
inputRules,
environments: ["IL2", "IL4", "IL5"],
}),
+ computed: {
+ isRequired() {
+ return (
+ this.dns.credentialName ||
+ this.dns.appHostname ||
+ this.dns.targetEnvironment
+ );
+ },
+ hint() {
+ return this.isRequired ? "* Required" : "";
+ },
+ },
watch: {
dns() {
this.$emit("input", this.dns);
diff --git a/tests/unit/components/MissionAppDns.spec.js b/tests/unit/components/MissionAppDns.spec.js
index bdf3000389a1ae2a44ea5007cab2655726a211d1..8bbca70f04d210f3032671a737475941fd891e8d 100644
--- a/tests/unit/components/MissionAppDns.spec.js
+++ b/tests/unit/components/MissionAppDns.spec.js
@@ -42,4 +42,20 @@ describe("Mission App Dns Form Section", () => {
wrapper.vm.environments[0]
);
});
+
+ describe("Required behavior | all or none", () => {
+ it("sets required to true if any of the fields are defined", () => {
+ inputs.at(0).setValue("dns-credentials");
+ expect(wrapper.vm.isRequired).toBeTruthy();
+ });
+
+ it("sets the hint to required if any of the fields are defined", () => {
+ inputs.at(0).setValue("dns-credentials");
+ expect(wrapper.vm.hint).toBe("* Required");
+ });
+
+ it("Does not return a hint if none of the fields are defined", () => {
+ expect(wrapper.vm.hint).toBe("");
+ });
+ });
});