2018-04-30 18:30:01 +02:00
|
|
|
const {
|
|
|
|
REQUIRED_ERROR,
|
|
|
|
INVALID_RECIPIENT_ADDRESS_ERROR,
|
|
|
|
} = require('../../send.constants')
|
2018-04-07 00:29:51 +02:00
|
|
|
const { isValidAddress } = require('../../../../util')
|
|
|
|
|
2018-06-14 15:55:55 +02:00
|
|
|
function getToErrorObject (to, toError = null) {
|
2018-04-07 00:29:51 +02:00
|
|
|
if (!to) {
|
2018-05-23 18:43:25 +02:00
|
|
|
toError = REQUIRED_ERROR
|
2018-06-14 15:55:55 +02:00
|
|
|
} else if (!isValidAddress(to) && !toError) {
|
2018-05-23 18:43:25 +02:00
|
|
|
toError = INVALID_RECIPIENT_ADDRESS_ERROR
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|
2018-04-27 02:38:14 +02:00
|
|
|
|
2018-04-07 00:29:51 +02:00
|
|
|
return { to: toError }
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2018-04-27 02:38:14 +02:00
|
|
|
getToErrorObject,
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|