data-validation-proximity 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +43 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -200,7 +200,7 @@ const validRoles = ['user', 'admin', 'seller', 'paymentManager', 'manager', 'Sup
200
200
 
201
201
  const userSchema = joi.object({
202
202
  email: joi.string().email(),
203
- phone: joi.string(),
203
+ phone: joi.string().allow(''),
204
204
  username: joi.string().min(5).required(),
205
205
  password: joi.string().min(6).required(),
206
206
  password_confirmation: joi.string().min(6).required(),
@@ -208,6 +208,27 @@ const userSchema = joi.object({
208
208
  cart: joi.string().allow(null).allow(''),
209
209
  google: joi.boolean(),
210
210
  profileImage: joi.string(),
211
+ // Google Sign-In fields for mobile authentication
212
+ serverAuthCode: joi.string().when('google', {
213
+ is: true,
214
+ then: joi.required(),
215
+ otherwise: joi.forbidden()
216
+ }),
217
+ googleId: joi.string().when('google', {
218
+ is: true,
219
+ then: joi.required(),
220
+ otherwise: joi.forbidden()
221
+ }),
222
+ photoUrl: joi.string().when('google', {
223
+ is: true,
224
+ then: joi.required(),
225
+ otherwise: joi.forbidden()
226
+ }),
227
+ displayName: joi.string().when('google', {
228
+ is: true,
229
+ then: joi.required(),
230
+ otherwise: joi.forbidden()
231
+ }),
211
232
  });
212
233
 
213
234
  exports.userSchemaValidation = createValidationMiddleware(userSchema);
@@ -231,6 +252,27 @@ const userLoginSchema = joi.object({
231
252
  password: joi.string().min(6),
232
253
  google: joi.boolean(),
233
254
  name: joi.string(),
255
+ // Google Sign-In fields for mobile authentication
256
+ serverAuthCode: joi.string().when('google', {
257
+ is: true,
258
+ then: joi.required(),
259
+ otherwise: joi.forbidden()
260
+ }),
261
+ googleId: joi.string().when('google', {
262
+ is: true,
263
+ then: joi.required(),
264
+ otherwise: joi.forbidden()
265
+ }),
266
+ photoUrl: joi.string().when('google', {
267
+ is: true,
268
+ then: joi.required(),
269
+ otherwise: joi.forbidden()
270
+ }),
271
+ displayName: joi.string().when('google', {
272
+ is: true,
273
+ then: joi.required(),
274
+ otherwise: joi.forbidden()
275
+ }),
234
276
  });
235
277
 
236
278
  exports.userLoginSchemaValidation = createValidationMiddleware(userLoginSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-validation-proximity",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "A library of Joi-based validation middlewares for Express.js",
5
5
  "main": "index.js",
6
6
  "license": "MIT",