sparcs-kaist / zabo-front-reactjs

Image and Poster Advertising Service @ KAIST
https://zabo.sparcs.org
MIT License
19 stars 7 forks source link

Input Form Validation #51

Closed jungdj closed 4 years ago

jungdj commented 4 years ago

관련 이슈 여기 정리

jungdj commented 4 years ago

그룹 이름 변경, 유저네임 변경

49

// variables.js
// ...
export const RESERVED_ROUTES_USERNAME_EXCEPTIONS = ['auth', 'settings'];

// utils/index.js 
// ...
export const validateName = (name) => {
  // 1~25자 제한
  if (name.length === 0 || name.length > 25) return false;
  // 첫 글자로는 _, 알파벳, 한글, 숫자만 입력 가능
  // ._- 한글 알파벳 숫자 입력 가능
  const patt = new RegExp (/^[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9_][ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9._-]*$/);
  if (!patt.test (name)) return false;
  const doubleCharPatt = /(--)|(\.\.)|(__)/;
  if (doubleCharPatt.test (name)) return false;
  const match = RESERVED_ROUTES_USERNAME_EXCEPTIONS.find (exception => exception === name.toLowerCase ());
  return !match;
};

요거 쓰면 됨

jungdj commented 4 years ago

RESERVED_ROUTES_USERNAME_EXCEPTIONS에 'admin' 추가

jungdj commented 4 years ago

https://github.com/sparcs-kaist/zabo-server-nodejs/issues/33

Choiyounseo commented 4 years ago

validate 함수 적용 완료