Explorar el Código

note-sync syncing

yukai hace 1 año
padre
commit
ea41d3e345
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      src/utils/validator.ts

+ 8 - 0
src/utils/validator.ts

@@ -13,4 +13,12 @@ export const phoneValidate = (rule: any, value: any, callback: any) => {
 
 export const ruleRequired = (message = '不能为空', trigger = 'blur') => {
   return { required: true, message, trigger }
+}
+
+export const validateNoSpace = (rule: any, value: any, callback: any) => {
+  if (/\s/.test(value)) {
+    callback(new Error('名称不能包含空格'));
+  } else {
+    callback();
+  }
 }