Skip to content

Commit

Permalink
fix(yup): try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Feb 18, 2021
1 parent 65e005b commit 5bfd276
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/validator/yup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import locale from 'yup/es/locale'
// @ts-ignore
import printValue from 'yup/es/util/printValue'

// 实现 getLocale 方法
Object.defineProperty(yup, 'getLocale', {
value: () => locale,
})
try {
// 实现 getLocale 方法
Object.defineProperty(yup, 'getLocale', {
value: () => locale,
})

// 实现 printValue 方法
Object.defineProperty(yup, 'printValue', {
value: printValue,
})
// 实现 printValue 方法
Object.defineProperty(yup, 'printValue', {
value: printValue,
})
} catch {}

// 实现 chineseMobilePhoneNumber 验证器
yup.addMethod(
Expand Down

0 comments on commit 5bfd276

Please sign in to comment.