Skip to content

Commit

Permalink
work for the surveyjs/private-tasks#242 (review)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Jul 27, 2023
1 parent f4c964c commit 631a4c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,21 @@ export class QuestionTextModel extends QuestionTextBase {
errors.push(maxError);
}

var name = this.name;
const valName = this.getValidatorTitle();
var emailValidator = new EmailValidator();
if (
this.inputType === "email" &&
!this.validators.some((v) => v.getType() === "emailvalidator") &&
emailValidator.validate(this.value, name)
!this.validators.some((v) => v.getType() === "emailvalidator")
) {
const maxError = new CustomError(
emailValidator.getErrorText(name),
this
);
errors.push(maxError);
const validateResult = emailValidator.validate(this.value, valName);

if (!!validateResult) {
const maxError = new CustomError(
validateResult.error.getText(),
this
);
errors.push(maxError);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SurveyValidator extends Base {
get locText(): LocalizableString {
return this.getLocalizableString("text");
}
public getErrorText(name: string): string {
protected getErrorText(name: string): string {
if (this.text) return this.text;
return this.getDefaultErrorText(name);
}
Expand Down

0 comments on commit 631a4c8

Please sign in to comment.