ember-changeset-cp-validations icon indicating copy to clipboard operation
ember-changeset-cp-validations copied to clipboard

Validation is marking fields as changed

Open mydea opened this issue 7 years ago • 1 comments

I have a model with two validations, a custom one and a has-many one.

Now, when using a changeset and changing a value, I get the following changes:

changeset.get('changes'); // -->[ {...} ]

However, when I then run changeset.validate(), suddenly I get both fields that have validation on them as well:

changeset.validate().then(() => {
  console.log(changeset.get('changes')); // --> [ {...}, {...}, {...}] 
});

The fields are only added after calling .validate(). I'm creating the changeset like this: createChangeset(myModel).

If I manually do this check:

changeset.get('change.validatedField') === model.get('validatedField')

it returns true, indicating that it indeed hasn't changed at all.

mydea avatar Jan 24 '17 15:01 mydea

@mydea I'm actually not too sure whats going on here. All this addon does is provide a validate function for ember-changeset to test values against. It has nothing to do with the change detection.

offirgolan avatar Jan 24 '17 20:01 offirgolan