angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

Array validation seems to be broken when additional items are added

Open Choc13 opened this issue 10 years ago • 6 comments

If an additional item is added to an array input field then it initially has the classes form-control, ng-invalid, ng-invalid-tv4-302, ng-empty, ng-invalid-schema-form, ng-touched, but I was expecting it to have form-control, ng-empty, ng-valid-schema-form, ng-touched.

Here is a Plunker showing this; just add an additional item to the array and it will immediately be in an invalid state.

Interestingly this doesn't seem to be the case for the array example on the demo site. This behaves as I would expect it to, I have a feeling this is using the version of the bootstrap decorators prior to them being moved to a separate repository and hence something seems to have changed in the latest version.

Also, this may or may not be related, but as soon as a second item is added to the array a Required validation message appears for the entire array object. This sort of makes sense given that the second item is invalid, but if I then remove the second item this validation message remains. Further still if I remove the first item then the Required validation message disappears, which is not what I would expect given that the comments item is required as part of the JSON schema and is now completely empty, so I would expect the required validation to trigger at this point.

Choc13 avatar Feb 17 '16 16:02 Choc13

+1 Agree that this is strange behaviour. I would expect that when a new item is added to the array, it should have an untouched state, and not show an error message until it has become dirty.

romiem avatar Feb 22 '16 14:02 romiem

The bug has been introduced in version 0.8.11. Check out a working example running 0.8.10 in this Plunker.

grobgl avatar May 13 '16 13:05 grobgl

@grobgl thank you for confirming that, a big help :)

Anthropic avatar May 13 '16 13:05 Anthropic

Getting rid of the firstDigest variable (which has been introduced in 0.8.11) entirely seems to fix the issue, but I'm not sure if that has any other implications.

grobgl avatar May 13 '16 14:05 grobgl

Is this also the root cause for this issue: Plunk?

Update: Seems not: Another Plunk

slyadams avatar Jul 21 '16 11:07 slyadams

This should be working in the latest alphas.

Anthropic avatar Apr 20 '17 13:04 Anthropic