Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

fix: correct overwritten regex type #106

Merged
merged 2 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/TextBoxField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type TextBoxFieldProps<T = TextBoxValue, K = string> = BaseFieldProps<T, K> &
className?: string
max?: number
min?: number
regex?: RegExp[]
regex?: (RegExp | RegExp[])[]
}

const TextBoxField = forwardRef(
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/mockErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const mockErrors: FormErrors = {
`This field should have a length greater than ${minLength}`,
REGEX: ({ regex }) =>
`This field should match the regex ${regex
.map(r => r.source)
.map(r => Array.isArray(r) ? r.map(nestedRegex => nestedRegex.source).join(' or ') : r.source )
.join(' and ')}`,
REQUIRED: 'This field is required',
TOO_HIGH: ({ max }) => `This field is too high (maximum is : ${max})`,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type RequiredErrors = {
| ((params: FormErrorFunctionParams & { maxLength: number }) => string)
| string
REGEX:
| ((params: FormErrorFunctionParams & { regex: RegExp[] }) => string)
| ((params: FormErrorFunctionParams & { regex: (RegExp | RegExp[])[] }) => string)
| string
REQUIRED: ((params: FormErrorFunctionParams) => string) | string
}
Expand Down