Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'validate') #130

Open
mdolega opened this issue Sep 25, 2021 · 2 comments
Open

Cannot read properties of undefined (reading 'validate') #130

mdolega opened this issue Sep 25, 2021 · 2 comments

Comments

@mdolega
Copy link

mdolega commented Sep 25, 2021

Hi, i have this part of code

@Form({
  validators: Validators.required
})
export class Login {
  @FormControl()
  email?: string;

  @FormControl()
  password?: string;
}

but, when call this.mapper.readForm(this.form, Login)i have an error, because in method
private isValidatorFn(value: any): boolean { return isFunction(value) && !value.prototype.validate; }

value.prototype is null

below part of exception:

ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'validate')
TypeError: Cannot read properties of undefined (reading 'validate')
    at ValidatorResolver.isValidatorFn (rx-form-mapper.js:324)
    at ValidatorResolver.resolve (rx-form-mapper.js:310)
    at rx-form-mapper.js:295
    at Array.map (<anonymous>)
    at FormWriter.buildAbstractControlOptions (rx-form-mapper.js:295)
    at FormWriter.visitFormMetadata (rx-form-mapper.js:291)
    at FormMetadata.accept (rx-form-mapper.js:78)
    at RxFormMapper.writeForm (rx-form-mapper.js:357)
@mohamadayash
Copy link

Hello , how are you

Please any news about this issue ?

@mohamadayash
Copy link

Solved it as following

private isValidatorFn(value: any): boolean {
return isFunction(value) && !value.prototype?.validate;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants