adiciona(atendimento, res) {
// const dataCriacao = new Date();
const dataCriacao = moment().format('YYYY-MM-DD HH:MM:SS')
const data = moment(atendimento.data, 'DD/MM/YYYY').format('YYYY-MM-DD HH:MM:SS')
const dataEhValida = moment(data).isSameOrAfter(dataCriacao)
const clienteEhValido = atendimento.cliente.length >= 5
console.log('TTT data = ' + data)
console.log('TTT dataCriacao = ' + dataCriacao)
console.log('TTT dataEhValida = ' + dataEhValida)
console.log('TTT ========================================')
Em algumas situações da erro na validação da data pois o resoltado do moment está dando segundos maior que 59
exemplo:
TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 13:04:16 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 13:04:66 <<<<= erro TTT dataEhValida = false <<<<= erro TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 13:04:86 <<<<= erro TTT dataEhValida = false <<<<= erro TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 13:04:96 <<<<= erro TTT dataEhValida = false <<<<= erroTTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 13:04:13 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:50 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:15 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:35 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:38 TTT dataEhValida = true TTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:89 <<<<= erro TTT dataEhValida = false <<<<= erroTTT ======================================== TTT data = 2020-10-11 00:10:00 TTT dataCriacao = 2020-04-05 14:04:32 TTT dataEhValida = true TTT ========================================