javascript - Angular Schema Form - Array validation -


i trying make array of unique values using schema form seems impossible task.

to keep things simple lets consider simple unique validator:

$scope.validateunique = function(value) {     console.log('running validation');     var samename = $scope.model.noduplicate.filter(function(item) {         return item.key === value;     });     return samename.length < 2; } 

open console , visit fiddle.

step 1: add new item called 1.

step 2: add new item called 12.

step 3: add new item called 123.

step 4: add new item called 1234.

so far good.

step 5: change first item (1) 1234 error message appears.

step 6: delete last item first 1 unique again. nothing happens. array not validated again once item removed , if click on submit button should trigger valdiation of form nothing happens.

is issue mistake? there mistake in example code? or sort of schema-form bug? how achieve revalidation of array either on removing of item or submitting form? thanks!

solved. not proud of solution far angular schema form array validation broken couldn't figure out better solution.

i have added form directive

$scope.$watch('formstate', () => {     teststartactions.updateformstatefromform(newval);     angular.foreach($scope.teststartform.$error.runtimeunique, (field) => {         field.$validate();     }); }, true); 

here working fiddle.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -