Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

sketchy validator patch #84

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/models/debit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const Debit = new mongoose.Schema({
type: String,
required: true,
ref: 'User',
validate: {
validator: value => utils.isValidEmail(value),
message: 'Invalid user email address'
}
},
created: {
type: Date,
Expand Down
6 changes: 1 addition & 5 deletions lib/models/payment-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ const PaymentProcessorSchema = new mongoose.Schema({
user: {
type: String,
ref: 'User',
required: true,
validate: {
validator: value => utils.isValidEmail(value),
message: 'Invalid user email address'
}
required: true
},
name: {
type: String,
Expand Down
6 changes: 0 additions & 6 deletions lib/models/pubkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ var PublicKey = new mongoose.Schema({
},
user: {
type: String,
validate: {
validator: function(v) {
return utils.isValidEmail(v);
},
message: '{VALUE} is not a valid email!'
},
ref: 'User'
},
label: {
Expand Down
6 changes: 1 addition & 5 deletions lib/models/storage-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ var StorageEvent = new mongoose.Schema({
user: {
type: String,
ref: 'User',
required: true,
Copy link
Contributor

@braydonf braydonf Mar 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain as true. And email validation should be consistent across all models. The validation should be fixed not removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@braydonf it is still true.. see line 25

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... okay. But why remove the validation?

validate: {
validator: value => utils.isValidEmail(value),
message: 'Invalid user email address'
}
required: true
},
timestamp: {
type: Date,
Expand Down
6 changes: 1 addition & 5 deletions lib/models/usernonce.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ var UserNonce = new mongoose.Schema({
user: {
type: String,
ref: 'User',
required: true,
validate: {
validator: value => utils.isValidEmail(value),
message: 'Invalid user email address'
}
required: true
},
nonce: {
type: String,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const moment = require('moment');

module.exports.isValidEmail = function (email) {
const tester = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; // jshint ignore:line
const tester = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-zA-Z\-0-9]+)(\.[a-zA-Z\-0-9]+){1,}))$/; // jshint ignore:line

if (email.length > 254) {
return false;
Expand Down