Skip to content
Permalink
Browse files

fix(validation): ignore hidden required fields (#175)

  • Loading branch information...
czosel committed May 1, 2019
1 parent 4d2cbef commit 2d1f490858ab7b682295b2c82b2d22dab95a4a67
Showing with 17 additions and 1 deletion.
  1. +1 −1 addon/lib/field.js
  2. +16 −0 tests/unit/lib/field-test.js
@@ -203,7 +203,7 @@ export default EmberObject.extend(Evented, {
*/
validate: task(function*() {
const validationFns = [
this._validateRequired,
...(!this.question.hidden ? [this._validateRequired] : []),
this.get(`_validate${this.question.__typename}`)
];

@@ -101,6 +101,22 @@ module("Unit | Library | field", function(hooks) {
assert.deepEqual(field.errors, ["This field can't be blank"]);
});

test("it ignores hidden required fields", async function(assert) {
assert.expect(1);

const field = Field.create(this.owner.ownerInjection(), {
_question: {
isRequired: "true",
hidden: true,
__typename: "TextQuestion"
},
_document: {}
});

await field.validate.perform();
assert.deepEqual(field.errors, []);
});

test("it can validate text fields", async function(assert) {
assert.expect(2);

0 comments on commit 2d1f490

Please sign in to comment.
You can’t perform that action at this time.