diff --git a/package.json b/package.json index a0295b83307..1ce993be311 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-hook-form", "description": "Performant, flexible and extensible forms library for React Hooks", - "version": "7.42.1", + "version": "7.42.2", "main": "dist/index.cjs.js", "module": "dist/index.esm.mjs", "umd:main": "dist/index.umd.js", diff --git a/src/logic/validateField.ts b/src/logic/validateField.ts index 01f4bc8981b..820bd0b978b 100644 --- a/src/logic/validateField.ts +++ b/src/logic/validateField.ts @@ -204,10 +204,10 @@ export default async ( } } - if (pattern && !isEmpty && isString(inputValue)) { + if (pattern && !isEmpty && (isString(inputValue) || valueAsNumber)) { const { value: patternValue, message } = getValueAndMessage(pattern); - if (isRegex(patternValue) && !inputValue.match(patternValue)) { + if (isRegex(patternValue) && !String(inputValue).match(patternValue)) { error[name] = { type: INPUT_VALIDATION_RULES.pattern, message,