huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame^] | 1 | /** |
| 2 | * Created by jiachenpan on 16/11/18. |
| 3 | */ |
| 4 | |
| 5 | export function isvalidUsername(str) { |
| 6 | const valid_map = ['admin', 'editor'] |
| 7 | return valid_map.indexOf(str.trim()) >= 0 |
| 8 | } |
| 9 | |
| 10 | /* 合法uri*/ |
| 11 | export function validateURL(textval) { |
| 12 | const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ |
| 13 | return urlregex.test(textval) |
| 14 | } |
| 15 | |
| 16 | /* 小写字母*/ |
| 17 | export function validateLowerCase(str) { |
| 18 | const reg = /^[a-z]+$/ |
| 19 | return reg.test(str) |
| 20 | } |
| 21 | |
| 22 | /* 大写字母*/ |
| 23 | export function validateUpperCase(str) { |
| 24 | const reg = /^[A-Z]+$/ |
| 25 | return reg.test(str) |
| 26 | } |
| 27 | |
| 28 | /* 大小写字母*/ |
| 29 | export function validatAlphabets(str) { |
| 30 | const reg = /^[A-Za-z]+$/ |
| 31 | return reg.test(str) |
| 32 | } |
| 33 | |