Browse Source

fix: 修复useValidator报错

kailong321200875 1 year ago
parent
commit
4912f6c058
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/hooks/web/useValidator.ts

+ 1 - 1
src/hooks/web/useValidator.ts

@@ -30,7 +30,7 @@ export const useValidator = () => {
   const notSpace = (message?: string): FormItemRule => {
     return {
       validator: (_, val, callback) => {
-        if (val.indexOf(' ') !== -1) {
+        if (val?.indexOf(' ') !== -1) {
           callback(new Error(message || t('common.notSpace')))
         } else {
           callback()