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.
 
 
 
 

23 lines
520 B

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