-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from alphamanuscript/master
v0.3.0
- Loading branch information
Showing
30 changed files
with
485 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as joi from '@hapi/joi'; | ||
import { phoneValidationSchema, passwordValidationSchema, googleIdTokenValidationSchema, emailValidationSchema, idValidationSchema } from '../util/validation-util'; | ||
import { phoneValidationSchema, passwordValidationSchema, googleIdTokenValidationSchema, emailValidationSchema, idValidationSchema, isAnonymousSchema } from '../util/validation-util'; | ||
|
||
const emailSchema = joi.string() | ||
.pattern(/\S+@\S+\.\S+/) // Simplest pattern ([email protected]) of email validation. Should be updated with a more rigorous, thorough pattern | ||
|
@@ -30,17 +30,34 @@ const userIdSchema = joi.object().keys({ | |
'string.empty': `Please enter userId`, | ||
'string.pattern.base': `Invalid userId. Must contain hexadecimals only and be 32 characters long` | ||
}), | ||
}) | ||
}); | ||
|
||
const amountSchema = joi.number() | ||
.required() | ||
.min(100) | ||
.messages({ | ||
'any.required': `Amount is required`, | ||
'number.base': 'Invalid type, amount must be a number', | ||
'number.min': `Amount must be 100 or more`, | ||
}) | ||
|
||
export const createInputSchema = joi.alternatives().try( | ||
joi.object().keys({ | ||
phone: phoneValidationSchema, | ||
password: passwordValidationSchema, | ||
name: joi.string().required(), | ||
email: emailSchema | ||
email: emailSchema, | ||
isAnonymous: isAnonymousSchema, | ||
}), | ||
joi.object().keys({ phone: phoneValidationSchema, googleIdToken: googleIdTokenValidationSchema }), | ||
);; | ||
); | ||
|
||
export const donateAnonymouslyInputSchema = joi.object().keys({ | ||
amount: amountSchema, | ||
name: joi.string().required(), | ||
phone: phoneValidationSchema, | ||
email: emailSchema, | ||
}); | ||
|
||
export const loginInputSchema = joi.alternatives().try( | ||
joi.object().keys({ phone: phoneValidationSchema, password: passwordValidationSchema }), | ||
|
@@ -110,14 +127,7 @@ export const logoutAllInputSchema = userIdSchema; | |
|
||
export const initiateDonationInputSchema = joi.object().keys({ | ||
userId: idValidationSchema, | ||
amount: joi.number() | ||
.required() | ||
.min(100) | ||
.messages({ | ||
'any.required': `amount is required`, | ||
'number.base': 'Invalid type, amount must be a number', | ||
'number.min': `amount must be 100 or more`, | ||
}) | ||
amount: amountSchema | ||
}); | ||
|
||
export const putInputSchema = joi.object().keys({ | ||
|
@@ -133,8 +143,8 @@ export const putInputSchema = joi.object().keys({ | |
name: joi.string() | ||
.required() | ||
.messages({ | ||
'any.required': 'name is required', | ||
'string.empty': 'name is required' | ||
'any.required': 'Name is required', | ||
'string.empty': 'Name is required' | ||
}), | ||
email: emailValidationSchema, | ||
password: passwordValidationSchema | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.