Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Nov 18, 2024
1 parent f3ab18a commit a3914ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions lib/validation/rules/maxLength.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { format } from '../../support/Num'
import { createRule } from '../Rule'
import { maxLength as baseMaxLength } from '../validators'

Expand All @@ -7,10 +8,8 @@ export const message = {
}

export function maxLength(length: number, msg?: string) {
const formatted = Intl.NumberFormat().format(length)

return createRule({
message: ({ lang }) => msg ?? message[lang](formatted),
message: ({ lang }) => msg ?? message[lang](format(length)),
optional: true,
validation: (value) => baseMaxLength(value, length)
})
Expand Down
5 changes: 2 additions & 3 deletions lib/validation/rules/maxValue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { format } from '../../support/Num'
import { createRule } from '../Rule'
import { maxValue as baseMaxValue } from '../validators'

Expand All @@ -7,10 +8,8 @@ export const message = {
}

export function maxValue(max: number, msg?: string) {
const formatted = Intl.NumberFormat().format(max)

return createRule({
message: ({ lang }) => msg ?? message[lang](formatted),
message: ({ lang }) => msg ?? message[lang](format(max)),
optional: true,
validation: (value) => baseMaxValue(value, max)
})
Expand Down
5 changes: 2 additions & 3 deletions lib/validation/rules/minLength.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { format } from '../../support/Num'
import { createRule } from '../Rule'
import { minLength as baseMinLength } from '../validators'

Expand All @@ -7,10 +8,8 @@ export const message = {
}

export function minLength(length: number, msg?: string) {
const formatted = Intl.NumberFormat().format(length)

return createRule({
message: ({ lang }) => msg ?? message[lang](formatted),
message: ({ lang }) => msg ?? message[lang](format(length)),
optional: true,
validation: (value) => baseMinLength(value, length)
})
Expand Down
5 changes: 2 additions & 3 deletions lib/validation/rules/minValue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { format } from '../../support/Num'
import { createRule } from '../Rule'
import { minValue as baseMinValue } from '../validators'

Expand All @@ -7,10 +8,8 @@ export const message = {
}

export function minValue(min: number, msg?: string) {
const formatted = Intl.NumberFormat().format(min)

return createRule({
message: ({ lang }) => msg ?? message[lang](formatted),
message: ({ lang }) => msg ?? message[lang](format(min)),
optional: true,
validation: (value) => baseMinValue(value, min)
})
Expand Down

0 comments on commit a3914ed

Please sign in to comment.