diff --git a/client/ios/DivKit/Extensions/DivInputExtensions.swift b/client/ios/DivKit/Extensions/DivInputExtensions.swift index ca955d1c9..6de8c9250 100644 --- a/client/ios/DivKit/Extensions/DivInputExtensions.swift +++ b/client/ios/DivKit/Extensions/DivInputExtensions.swift @@ -91,7 +91,7 @@ extension DivInput { return TextInputValidator( isValid: context.makeBinding(variableName: regexValidator.variable, defaultValue: false), allowEmpty: regexValidator.resolveAllowEmpty(expressionResolver), - validator: { $0.matchesRegex(regex) }, + validator: { $0.fullMatchesRegex(regex) }, message: makeMessage( from: regexValidator.resolveLabelId(expressionResolver), storage: context.blockStateStorage, @@ -231,3 +231,11 @@ extension DivFixedLengthInputMask.PatternElement { ) } } + +extension String { + fileprivate func fullMatchesRegex(_ regex: NSRegularExpression) -> Bool { + let range = stringRangeAsNSRange(wholeStringRange, inString: self) + return regex.matches(in: self, options: [], range: range) + .contains { $0.range == range } + } +}