Commit fb8518ec authored by Kim, Subin's avatar Kim, Subin
Browse files

주문자정보 전화번호 유효성 검사 완료

parent 1f9aa29d
...@@ -220,6 +220,11 @@ function Payment({ match, location }) { ...@@ -220,6 +220,11 @@ function Payment({ match, location }) {
} }
} }
if (error) {
alert(`${error}`)
setError('')
}
return ( return (
<Container className="mb-5"> <Container className="mb-5">
<h3 className="my-5 font-weight-bold text-center">주문/결제</h3> <h3 className="my-5 font-weight-bold text-center">주문/결제</h3>
......
...@@ -6,6 +6,9 @@ import Product from "../schemas/Product.js"; ...@@ -6,6 +6,9 @@ import Product from "../schemas/Product.js";
const addorder = async (req, res) => { const addorder = async (req, res) => {
const { userId, products, receiverInfo, total } = req.body const { userId, products, receiverInfo, total } = req.body
try { try {
if (!/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}/.test(receiverInfo.tel)) {
return res.status(422).send('유효한 휴대전화번호가 아닙니다. 정확히 입력해주세요.')
}
const newOrder = await new Order({ userId, products, receiverInfo, total }).save() const newOrder = await new Order({ userId, products, receiverInfo, total }).save()
res.status(200).send('Order DB에 저장 완료') res.status(200).send('Order DB에 저장 완료')
} catch (error) { } catch (error) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment