You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
537 B

const fields = ["nome", "r_g", "c_p_f", "data_de_nascimento", "endereco", "telefone"]
const data = _val.map();
const errors = _val.list();
for (field of fields) {
const value = _req.getString(field);
if (!value) {
errors.add(field);
} else {
data.set(field, value);
}
}
if (errors.isEmpty()) {
const insertedData = _db.insertIfNotExists(
'paciente',
data
);
_out.json({insertedData})
} else {
_header.status(400);
_out.json({"erros": {"campos faltando": errors}})
}