Return Sequelize Array from String or String Array After Filtering
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
My main concern is if this is the most efficient way to filter, and subsequently search for, the three type of values.
Here are my helper methods and their return data type:
_.email.isValidText(string) : boolean
_.strings.isValid(string) : boolean
_.strings.isDigits(string) : boolean
_.uuid.isValidUid(string) : boolean
_.strings.toLowerCase(string || string) : string || string
I'm trying to validate between three types of values:
SMTP/Email Address
10-digit Phone Number
prefixed 10-digit Phone Number (uid.xxxxxxxxxx)
The _d
is a soft delete field (timestamp
) which indicates when / if the row was deleted.
function getByAddress (valueOrValues, done)
valueOrValues = .concat(valueOrValues).filter(_.strings.isValid).map(_.strings.toLowerCase);
var email = valueOrValues.filter(_.email.isValidText);
var outgoing = valueOrValues.filter(_.strings.isDigits);
var incoming = valueOrValues.filter(function(v)
var parts = v.split('.');
return (parts.length === 2 && _.uuid.isValidUid(parts[0]) && _.strings.isDigits(parts[1]));
);
var valid = .concat(email, outgoing, incoming);
var invalid = valueOrValues.filter(function(v)
return (valid.indexOf(v) < 0);
);
if (invalid.length > 0) return done('create : invalid values supplied');
models.mailbox_address.findAll(
where :
address : $in : .concat(email, outgoing, incoming) ,
_d : $eq : null ,
)
.then(function(items)
return done(null, items);
)
.catch(function(err)
return done(err);
);
javascript node.js
add a comment |Â
up vote
0
down vote
favorite
My main concern is if this is the most efficient way to filter, and subsequently search for, the three type of values.
Here are my helper methods and their return data type:
_.email.isValidText(string) : boolean
_.strings.isValid(string) : boolean
_.strings.isDigits(string) : boolean
_.uuid.isValidUid(string) : boolean
_.strings.toLowerCase(string || string) : string || string
I'm trying to validate between three types of values:
SMTP/Email Address
10-digit Phone Number
prefixed 10-digit Phone Number (uid.xxxxxxxxxx)
The _d
is a soft delete field (timestamp
) which indicates when / if the row was deleted.
function getByAddress (valueOrValues, done)
valueOrValues = .concat(valueOrValues).filter(_.strings.isValid).map(_.strings.toLowerCase);
var email = valueOrValues.filter(_.email.isValidText);
var outgoing = valueOrValues.filter(_.strings.isDigits);
var incoming = valueOrValues.filter(function(v)
var parts = v.split('.');
return (parts.length === 2 && _.uuid.isValidUid(parts[0]) && _.strings.isDigits(parts[1]));
);
var valid = .concat(email, outgoing, incoming);
var invalid = valueOrValues.filter(function(v)
return (valid.indexOf(v) < 0);
);
if (invalid.length > 0) return done('create : invalid values supplied');
models.mailbox_address.findAll(
where :
address : $in : .concat(email, outgoing, incoming) ,
_d : $eq : null ,
)
.then(function(items)
return done(null, items);
)
.catch(function(err)
return done(err);
);
javascript node.js
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
@200_success : done
â G. Deward
Feb 7 at 19:43
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My main concern is if this is the most efficient way to filter, and subsequently search for, the three type of values.
Here are my helper methods and their return data type:
_.email.isValidText(string) : boolean
_.strings.isValid(string) : boolean
_.strings.isDigits(string) : boolean
_.uuid.isValidUid(string) : boolean
_.strings.toLowerCase(string || string) : string || string
I'm trying to validate between three types of values:
SMTP/Email Address
10-digit Phone Number
prefixed 10-digit Phone Number (uid.xxxxxxxxxx)
The _d
is a soft delete field (timestamp
) which indicates when / if the row was deleted.
function getByAddress (valueOrValues, done)
valueOrValues = .concat(valueOrValues).filter(_.strings.isValid).map(_.strings.toLowerCase);
var email = valueOrValues.filter(_.email.isValidText);
var outgoing = valueOrValues.filter(_.strings.isDigits);
var incoming = valueOrValues.filter(function(v)
var parts = v.split('.');
return (parts.length === 2 && _.uuid.isValidUid(parts[0]) && _.strings.isDigits(parts[1]));
);
var valid = .concat(email, outgoing, incoming);
var invalid = valueOrValues.filter(function(v)
return (valid.indexOf(v) < 0);
);
if (invalid.length > 0) return done('create : invalid values supplied');
models.mailbox_address.findAll(
where :
address : $in : .concat(email, outgoing, incoming) ,
_d : $eq : null ,
)
.then(function(items)
return done(null, items);
)
.catch(function(err)
return done(err);
);
javascript node.js
My main concern is if this is the most efficient way to filter, and subsequently search for, the three type of values.
Here are my helper methods and their return data type:
_.email.isValidText(string) : boolean
_.strings.isValid(string) : boolean
_.strings.isDigits(string) : boolean
_.uuid.isValidUid(string) : boolean
_.strings.toLowerCase(string || string) : string || string
I'm trying to validate between three types of values:
SMTP/Email Address
10-digit Phone Number
prefixed 10-digit Phone Number (uid.xxxxxxxxxx)
The _d
is a soft delete field (timestamp
) which indicates when / if the row was deleted.
function getByAddress (valueOrValues, done)
valueOrValues = .concat(valueOrValues).filter(_.strings.isValid).map(_.strings.toLowerCase);
var email = valueOrValues.filter(_.email.isValidText);
var outgoing = valueOrValues.filter(_.strings.isDigits);
var incoming = valueOrValues.filter(function(v)
var parts = v.split('.');
return (parts.length === 2 && _.uuid.isValidUid(parts[0]) && _.strings.isDigits(parts[1]));
);
var valid = .concat(email, outgoing, incoming);
var invalid = valueOrValues.filter(function(v)
return (valid.indexOf(v) < 0);
);
if (invalid.length > 0) return done('create : invalid values supplied');
models.mailbox_address.findAll(
where :
address : $in : .concat(email, outgoing, incoming) ,
_d : $eq : null ,
)
.then(function(items)
return done(null, items);
)
.catch(function(err)
return done(err);
);
javascript node.js
edited Feb 7 at 19:43
asked Feb 7 at 19:33
G. Deward
1945
1945
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
@200_success : done
â G. Deward
Feb 7 at 19:43
add a comment |Â
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
@200_success : done
â G. Deward
Feb 7 at 19:43
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
@200_success : done
â G. Deward
Feb 7 at 19:43
@200_success : done
â G. Deward
Feb 7 at 19:43
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f187046%2freturn-sequelize-array-from-string-or-string-array-after-filtering%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Please edit the question to clarify what the code accomplishes, with examples. Also retitle the question to state the task accomplished by the code, rather than your main concern about the code. See How to Ask.
â 200_success
Feb 7 at 19:36
@200_success : done
â G. Deward
Feb 7 at 19:43