UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

31 lines 1.17 kB
import { StringUtils } from "../Utils/StringUtils"; import { InputTextValidatorResult } from "./InputTextValidatorResult"; export class InputTextValidator { constructor(userConfirmationDelegate = null) { this._userConfirmationDelegate = userConfirmationDelegate; } get userConfirmationDelegate() { return this._userConfirmationDelegate; } set userConfirmationDelegate(value) { this._userConfirmationDelegate = value; } async validateWithConfirmation(text) { let isTextValid = true; let isInputConfirmed = null; if (!this.validate(text)) { isTextValid = false; isInputConfirmed = await this._requestUserConfirmation("rtl-chars"); } return Promise.resolve(new InputTextValidatorResult(isTextValid, isInputConfirmed)); } validate(text) { return !StringUtils.containsRtlChars(text); } _requestUserConfirmation(type) { return this._userConfirmationDelegate ? this._userConfirmationDelegate(type) : Promise.resolve(true); } } //# sourceMappingURL=InputTextValidator.js.map