dataease-dm/frontend/src/utils/validate.js

23 lines
501 B
JavaScript
Raw Normal View History

2021-03-03 15:06:52 +08:00
/**
* Created by PanJiaChen on 16/11/18.
*/
/**
* @param {string} path
* @returns {Boolean}
*/
export function isExternal(path) {
2022-03-31 17:52:22 +08:00
return /^(https?:|mailto:|tel:)/.test(path) || /^(http?:|mailto:|tel:)/.test(path) || path.startsWith('/api/pluginCommon/staticInfo')
2021-03-03 15:06:52 +08:00
}
/**
* @param {string} str
* @returns {Boolean}
*/
export function validUsername(str) {
2021-03-05 16:07:44 +08:00
const valid_map = ['admin', 'cyw']
2021-03-03 15:06:52 +08:00
return valid_map.indexOf(str.trim()) >= 0
}
2021-03-10 18:26:53 +08:00
export const PHONE_REGEX = '^1[3|4|5|7|8][0-9]{9}$'