diff --git a/src/string.ts b/src/string.ts index ca46393d8..bf580fa9b 100644 --- a/src/string.ts +++ b/src/string.ts @@ -105,26 +105,24 @@ export default class StringSchema< }); } - matches(regex: RegExp, options: MatchOptions | MatchOptions['message']) { + matches(regex: RegExp, options: MatchOptions | MatchOptions['message'] = locale.matches) { let excludeEmptyString = false; let message; let name; - if (options) { - if (typeof options === 'object') { - ({ - excludeEmptyString = false, - message, - name, - } = options as MatchOptions); - } else { - message = options; - } + if (typeof options === 'object') { + ({ + excludeEmptyString = false, + message, + name, + } = options as MatchOptions); + } else { + message = options; } return this.test({ name: name || 'matches', - message: message || locale.matches, + message, params: { regex }, test: (value: Maybe) => isAbsent(value) ||