유효성 검사(2)
-
express 유효성 검사 방법 [ express-validator ]
개발을 진행 할 때 if문 범벅이 되어서 코드 작성이 가독성이 떨어진다. express-validator는 if문 범벅 유효성 검사를 아주 간단하게 유효성 검사를 도와주는 라이브러리다 if문 범벅 예시 if (!index || !stageCheck || !playTime) { console.log('데이터가 없습니다. 1') } else if ( typeof index !== 'number' || typeof stageCheck !== 'string' || typeof playTime !== 'number' ) { console.log('타입 형식을 맞춰주세요, 2') } express-validator 사용 시 const { validationResult, body } = require('express..
2022.05.23 -
Vue (Vuetify) v-from, v-text-field 에서 유효성 검사 하기
Vuetify에서 v-text-field에 유효성 규칙을 지정하는 방법 1. v-text-field 생성 v-text-field를 만든다. :rules에 가져올 규칙이름을 넣어준다 2. 규칙 생성 data: () => ({ email: '', password: '', passwordShow: false, autoLoginCheckBox:false, emailRule:[ v => !!v || '이메일을 입력해주세요.', v => { const replaceV = v.replace(/(\s*)/g, '') const pattern = /^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/ return pattern.t..
2021.09.01