Skip to content

Commit

Permalink
[@mantine/form] Fix incorrect validators types (#7242)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Dec 12, 2024
1 parent 7f47aef commit 296fb8f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function isLengthValid(payload: HasLengthPayload, value: any) {
export function hasLength(payload: HasLengthPayload, error?: React.ReactNode) {
const _error = error || true;

return (value: unknown) => {
return (value: unknown): React.ReactNode => {
if (typeof value === 'string') {
return isLengthValid(payload, value.trim()) ? null : _error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface IsInRangePayload {
export function isInRange({ min, max }: IsInRangePayload, error?: React.ReactNode) {
const _error = error || true;

return (value: unknown) => {
return (value: unknown): React.ReactNode => {
if (typeof value !== 'number') {
return _error;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function isNotEmpty(error?: React.ReactNode) {
const _error = error || true;

return (value: unknown) => {
return (value: unknown): React.ReactNode => {
if (typeof value === 'string') {
return value.trim().length > 0 ? null : _error;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function matchesField(field: string, error?: React.ReactNode) {
const _error = error || true;

return (value: unknown, values: Record<string, unknown>) => {
return (value: unknown, values: Record<string, unknown>): React.ReactNode => {
if (!values || !(field in values)) {
return _error;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@mantine/form/src/validators/matches/matches.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function matches(regexp: RegExp, error?: React.ReactNode) {
const _error = error || true;

return (value: unknown) => {
return (value: unknown): React.ReactNode => {
if (typeof value !== 'string') {
return _error;
}
Expand Down

0 comments on commit 296fb8f

Please sign in to comment.