Skip to content
This repository was archived by the owner on Sep 20, 2025. It is now read-only.

Commit e004b16

Browse files
committed
Add more validation for new userAddress.telephone field
1 parent 0ca73bd commit e004b16

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/models/v1/userAddress.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,20 @@ module.exports = (sequelize, DataTypes) => {
165165
return "The state field is required.";
166166
}
167167

168+
if (payload.telephoneAreaCode) {
169+
if ("string" !== typeof payload.telephoneAreaCode) {
170+
return "The telephone area code field must be of type string.";
171+
} else if (6 < payload.telephoneAreaCode.length) {
172+
return "The telephone area code field must not be greater than 6 characters.";
173+
}
174+
}
175+
168176
if (!payload.telephone) {
169177
return "The telephone field is required.";
178+
} else if ("string" !== typeof payload.telephone) {
179+
return "The telephone field must be of type string.";
180+
} else if (30 < payload.telephone.length) {
181+
return "The telephone field must not be greater than 30 characters.";
170182
}
171183

172184
const userAddresses = await this.

0 commit comments

Comments
 (0)