form-example icon indicating copy to clipboard operation
form-example copied to clipboard

Can't use async validators, Object doesn't support property or method 'map'

Open benjamin-wilson opened this issue 7 years ago • 4 comments

In validate.ts:

return asyncValidator(control).map(v => {
        const secondary = synchronousValid();
        if (secondary || v) { // compose async and sync validator results
          return Object.assign({}, secondary, v);
        }
});

asyncValidator(control) is not an array

My validator looks like this:

...
@Directive({
    selector: "[selector-name][ngModel]",
    providers: [
        {
            provide: NG_ASYNC_VALIDATORS, useExisting: SelectorClass, multi: true
        }
    ]
})

export class SelectorClass implements Validator {
...

benjamin-wilson avatar Mar 17 '17 19:03 benjamin-wilson

same issue, my build fails with the source code provided

nrgjack avatar Mar 23 '17 08:03 nrgjack

anyone found a solution?

goncalolucas avatar Jul 24 '17 11:07 goncalolucas

We ended up moving to reactive forms when we couldn't figure out how to do nested forms/validation with ngModel

benjamin-wilson avatar Aug 02 '17 23:08 benjamin-wilson

@benjamin-wilson did you try this out https://github.com/GFoley83/form-example/tree/feature/support-reactive-form

genuinefafa avatar Jan 17 '18 21:01 genuinefafa