diff --git a/src/controllers/pendencias-controller.js b/src/controllers/pendencias-controller.js index b90553ee..083eeb78 100644 --- a/src/controllers/pendencias-controller.js +++ b/src/controllers/pendencias-controller.js @@ -1128,7 +1128,7 @@ export const aprovarPendencia = async (alteracao, hcf, transaction) => { } if (alteracao.cor !== undefined) { - updateTombo.cor = alteracao.cor.toUpperCase(); + updateTombo.cor = alteracao.cor ? alteracao.cor.toUpperCase() : null; } if (alteracao.data_coleta_dia !== undefined) { @@ -1156,196 +1156,237 @@ export const aprovarPendencia = async (alteracao, hcf, transaction) => { } if (alteracao.latitude !== undefined) { - updateTombo.latitude = typeof alteracao.latitude === 'string' - ? converteParaDecimal(alteracao.latitude) - : alteracao.latitude; + let latitudeValue = null; + if (alteracao.latitude !== null) { + if (typeof alteracao.latitude === 'string') { + latitudeValue = converteParaDecimal(alteracao.latitude); + } else { + latitudeValue = alteracao.latitude; + } + } + updateTombo.latitude = latitudeValue; } if (alteracao.longitude !== undefined) { - updateTombo.longitude = typeof alteracao.longitude === 'string' - ? converteParaDecimal(alteracao.longitude) - : alteracao.longitude; + let longitudeValue = null; + if (alteracao.longitude !== null) { + if (typeof alteracao.longitude === 'string') { + longitudeValue = converteParaDecimal(alteracao.longitude); + } else { + longitudeValue = alteracao.longitude; + } + } + updateTombo.longitude = longitudeValue; } if (alteracao.altitude !== undefined) { updateTombo.altitude = alteracao.altitude; } - if (alteracao.entidade_id) { - const herbario = await Herbario.findOne({ - where: { id: alteracao.entidade_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.entidade_id !== undefined) { + if (alteracao.entidade_id !== null) { + const herbario = await Herbario.findOne({ + where: { id: alteracao.entidade_id }, + transaction, + raw: true, + nest: true, + }); - if (!herbario) { - throw new BadRequestExeption(404); + if (!herbario) { + throw new BadRequestExeption(404); + } } updateTombo.entidade_id = alteracao.entidade_id; } - if (alteracao.tipo_id) { - const tipo = await Tipo.findOne({ - where: { id: alteracao.tipo_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.tipo_id !== undefined) { + if (alteracao.tipo_id !== null) { + const tipo = await Tipo.findOne({ + where: { id: alteracao.tipo_id }, + transaction, + raw: true, + nest: true, + }); - if (!tipo) { - throw new BadRequestExeption(404); + if (!tipo) { + throw new BadRequestExeption(404); + } } updateTombo.tipo_id = alteracao.tipo_id; } - if (alteracao.familia_id) { - const familia = await Familia.findOne({ - where: { id: alteracao.familia_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.familia_id !== undefined) { + if (alteracao.familia_id !== null) { + const familia = await Familia.findOne({ + where: { id: alteracao.familia_id }, + transaction, + raw: true, + nest: true, + }); - if (!familia) { - throw new BadRequestExeption(404); + if (!familia) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(familia.nome); } updateTombo.familia_id = alteracao.familia_id; - nomesCientificosPartes.push(familia.nome); - updateTombo.sub_familia_id = null; - updateTombo.genero_id = null; - updateTombo.especie_id = null; - updateTombo.sub_especie_id = null; - updateTombo.variedade_id = null; + if (alteracao.familia_id === null) { + updateTombo.sub_familia_id = null; + updateTombo.genero_id = null; + updateTombo.especie_id = null; + updateTombo.sub_especie_id = null; + updateTombo.variedade_id = null; + } } - if (alteracao.sub_familia_id) { - const subfamilia = await Subfamilia.findOne({ - where: { - id: alteracao.sub_familia_id, - familia_id: updateTombo.familia_id || tomboAtual.familia_id, - }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.sub_familia_id !== undefined) { + if (alteracao.sub_familia_id !== null) { + const subfamilia = await Subfamilia.findOne({ + where: { + id: alteracao.sub_familia_id, + familia_id: updateTombo.familia_id || tomboAtual.familia_id, + }, + transaction, + raw: true, + nest: true, + }); - if (!subfamilia) { - throw new BadRequestExeption(404); + if (!subfamilia) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(subfamilia.nome); } updateTombo.sub_familia_id = alteracao.sub_familia_id; - nomesCientificosPartes.push(subfamilia.nome); - updateTombo.genero_id = null; - updateTombo.especie_id = null; - updateTombo.sub_especie_id = null; - updateTombo.variedade_id = null; + if (alteracao.sub_familia_id === null) { + updateTombo.genero_id = null; + updateTombo.especie_id = null; + updateTombo.sub_especie_id = null; + updateTombo.variedade_id = null; + } } - if (alteracao.genero_id) { - const genero = await Genero.findOne({ - where: { - id: alteracao.genero_id, - familia_id: updateTombo.familia_id || tomboAtual.familia_id, - }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.genero_id !== undefined) { + if (alteracao.genero_id !== null) { + const genero = await Genero.findOne({ + where: { + id: alteracao.genero_id, + familia_id: updateTombo.familia_id || tomboAtual.familia_id, + }, + transaction, + raw: true, + nest: true, + }); - if (!genero) { - throw new BadRequestExeption(404); + if (!genero) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(genero.nome); } updateTombo.genero_id = alteracao.genero_id; - nomesCientificosPartes.push(genero.nome); - updateTombo.especie_id = null; - updateTombo.sub_especie_id = null; - updateTombo.variedade_id = null; + if (alteracao.genero_id === null) { + updateTombo.especie_id = null; + updateTombo.sub_especie_id = null; + updateTombo.variedade_id = null; + } } - if (alteracao.especie_id) { - const especie = await Especie.findOne({ - where: { - id: alteracao.especie_id, - genero_id: updateTombo.genero_id || tomboAtual.genero_id, - }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.especie_id !== undefined) { + if (alteracao.especie_id !== null) { + const especie = await Especie.findOne({ + where: { + id: alteracao.especie_id, + genero_id: updateTombo.genero_id || tomboAtual.genero_id, + }, + transaction, + raw: true, + nest: true, + }); - if (!especie) { - throw new BadRequestExeption(404); + if (!especie) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(especie.nome); } updateTombo.especie_id = alteracao.especie_id; - nomesCientificosPartes.push(especie.nome); - updateTombo.sub_especie_id = null; - updateTombo.variedade_id = null; + if (alteracao.especie_id === null) { + updateTombo.sub_especie_id = null; + updateTombo.variedade_id = null; + } } - if (alteracao.sub_especie_id) { - const subespecie = await Subespecie.findOne({ - where: { - id: alteracao.sub_especie_id, - especie_id: updateTombo.especie_id || tomboAtual.especie_id, - }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.sub_especie_id !== undefined) { + if (alteracao.sub_especie_id !== null) { + const subespecie = await Subespecie.findOne({ + where: { + id: alteracao.sub_especie_id, + especie_id: updateTombo.especie_id || tomboAtual.especie_id, + }, + transaction, + raw: true, + nest: true, + }); - if (!subespecie) { - throw new BadRequestExeption(404); + if (!subespecie) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(subespecie.nome); } updateTombo.sub_especie_id = alteracao.sub_especie_id; - nomesCientificosPartes.push(subespecie.nome); - updateTombo.variedade_id = null; + if (alteracao.sub_especie_id === null) { + updateTombo.variedade_id = null; + } } - if (alteracao.variedade_id) { - const variedade = await Variedade.findOne({ - where: { - id: alteracao.variedade_id, - especie_id: updateTombo.especie_id || tomboAtual.especie_id, - }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.variedade_id !== undefined) { + if (alteracao.variedade_id !== null) { + const variedade = await Variedade.findOne({ + where: { + id: alteracao.variedade_id, + especie_id: updateTombo.especie_id || tomboAtual.especie_id, + }, + transaction, + raw: true, + nest: true, + }); - if (!variedade) { - throw new BadRequestExeption(404); + if (!variedade) { + throw new BadRequestExeption(404); + } + nomesCientificosPartes.push(variedade.nome); } updateTombo.variedade_id = alteracao.variedade_id; - nomesCientificosPartes.push(variedade.nome); } if (nomesCientificosPartes.length > 0) { updateTombo.nome_cientifico = nomesCientificosPartes.join(' '); + } else if (Object.keys(updateTombo).some(key => key.includes('familia_id') || key.includes('genero_id') || key.includes('especie_id') || key.includes('sub_especie_id') || key.includes('variedade_id'))) { + updateTombo.nome_cientifico = null; } - if (alteracao.local_coleta_id) { - const localColeta = await LocalColeta.findOne({ - where: { id: alteracao.local_coleta_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.local_coleta_id !== undefined) { + if (alteracao.local_coleta_id !== null) { + const localColeta = await LocalColeta.findOne({ + where: { id: alteracao.local_coleta_id }, + transaction, + raw: true, + nest: true, + }); - if (!localColeta) { - throw new BadRequestExeption(404); + if (!localColeta) { + throw new BadRequestExeption(404); + } } - updateTombo.local_coleta_id = alteracao.local_coleta_id; } @@ -1353,73 +1394,77 @@ export const aprovarPendencia = async (alteracao, hcf, transaction) => { updateTombo.descricao = alteracao.descricao; } - if (alteracao.solo_id) { - const solo = await Solo.findOne({ - where: { id: alteracao.solo_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.solo_id !== undefined) { + if (alteracao.solo_id !== null) { + const solo = await Solo.findOne({ + where: { id: alteracao.solo_id }, + transaction, + raw: true, + nest: true, + }); - if (!solo) { - throw new BadRequestExeption(404); + if (!solo) { + throw new BadRequestExeption(404); + } } - updateTombo.solo_id = alteracao.solo_id; } - if (alteracao.relevo_id) { - const relevo = await Relevo.findOne({ - where: { id: alteracao.relevo_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.relevo_id !== undefined) { + if (alteracao.relevo_id !== null) { + const relevo = await Relevo.findOne({ + where: { id: alteracao.relevo_id }, + transaction, + raw: true, + nest: true, + }); - if (!relevo) { - throw new BadRequestExeption(404); + if (!relevo) { + throw new BadRequestExeption(404); + } } - updateTombo.relevo_id = alteracao.relevo_id; } - if (alteracao.vegetacao_id) { - const vegetacao = await Vegetacao.findOne({ - where: { id: alteracao.vegetacao_id }, - transaction, - raw: true, - nest: true, - }); + if (alteracao.vegetacao_id !== undefined) { + if (alteracao.vegetacao_id !== null) { + const vegetacao = await Vegetacao.findOne({ + where: { id: alteracao.vegetacao_id }, + transaction, + raw: true, + nest: true, + }); - if (!vegetacao) { - throw new BadRequestExeption(404); + if (!vegetacao) { + throw new BadRequestExeption(404); + } } - updateTombo.vegetacao_id = alteracao.vegetacao_id; } - if (alteracao.coletor_id) { - const coletor = await Coletor.findOne({ - where: { id: alteracao.coletor_id }, - transaction, - raw: true, - nest: true, - }); - - if (!coletor) { - throw new BadRequestExeption(404); - } - - const numeroColeta = updateTombo.numero_coleta; - if (numeroColeta && coletor.numero && coletor.numero < numeroColeta) { - await Coletor.update({ - numero: numeroColeta, - }, { + if (alteracao.coletor_id !== undefined) { + if (alteracao.coletor_id !== null) { + const coletor = await Coletor.findOne({ where: { id: alteracao.coletor_id }, transaction, + raw: true, + nest: true, }); - } + if (!coletor) { + throw new BadRequestExeption(404); + } + + const numeroColeta = updateTombo.numero_coleta; + if (numeroColeta && coletor.numero && coletor.numero < numeroColeta) { + await Coletor.update({ + numero: numeroColeta, + }, { + where: { id: alteracao.coletor_id }, + transaction, + }); + } + } updateTombo.coletor_id = alteracao.coletor_id; } @@ -1430,32 +1475,34 @@ export const aprovarPendencia = async (alteracao, hcf, transaction) => { }); } - if (alteracao.identificadores && Array.isArray(alteracao.identificadores)) { + if (alteracao.identificadores !== undefined) { await TomboIdentificador.destroy({ where: { tombo_hcf: hcf }, transaction, }); - const identificadoresPromises = alteracao.identificadores.map(async (identificadorId, index) => { - const identificador = await Identificador.findOne({ - where: { id: identificadorId }, - transaction, - raw: true, - nest: true, - }); + if (Array.isArray(alteracao.identificadores) && alteracao.identificadores.length > 0) { + const identificadoresPromises = alteracao.identificadores.map(async (identificadorId, index) => { + const identificador = await Identificador.findOne({ + where: { id: identificadorId }, + transaction, + raw: true, + nest: true, + }); - if (!identificador) { - throw new BadRequestExeption(404); - } + if (!identificador) { + throw new BadRequestExeption(404); + } - return TomboIdentificador.create({ - tombo_hcf: hcf, - identificador_id: identificadorId, - ordem: index + 1, - }, { transaction }); - }); + return TomboIdentificador.create({ + tombo_hcf: hcf, + identificador_id: identificadorId, + ordem: index + 1, + }, { transaction }); + }); - await Promise.all(identificadoresPromises); + await Promise.all(identificadoresPromises); + } } if (alteracao.complementares !== undefined) { @@ -1526,8 +1573,6 @@ export const aprovarPendencia = async (alteracao, hcf, transaction) => { }; }; -// ...existing code... - export const visualizarComJsonNome = (alteracao, hcf, transaction) => new Promise((resolve, reject) => { Tombo.findOne({ where: { @@ -1690,7 +1735,7 @@ export async function visualizar(request, response, next) { const objetoAlterado = JSON.parse(alteracao.tombo_json); const parametros = {}; - + if (objetoAlterado.nomes_populares) parametros.nome_popular = objetoAlterado.nomes_populares; if (objetoAlterado.numero_coleta) parametros.numero_coleta = objetoAlterado.numero_coleta; if (objetoAlterado.data_coleta?.dia) parametros.data_coleta_dia = objetoAlterado.data_coleta.dia; diff --git a/src/controllers/tombos-controller.js b/src/controllers/tombos-controller.js index 8e0398f2..0e524283 100644 --- a/src/controllers/tombos-controller.js +++ b/src/controllers/tombos-controller.js @@ -411,22 +411,22 @@ function alteracaoIdentificador(request, transaction) { const { tombo_id: tomboId } = request.params; const update = {}; - if (familiaId) { + if (familiaId !== undefined) { update.familia_id = familiaId; } - if (subfamiliaId) { + if (subfamiliaId !== undefined) { update.subfamilia_id = subfamiliaId; } - if (generoId) { + if (generoId !== undefined) { update.genero_id = generoId; } - if (especieId) { + if (especieId !== undefined) { update.especie_id = especieId; } - if (subespecieId) { + if (subespecieId !== undefined) { update.subespecie_id = subespecieId; } - if (variedadeId) { + if (variedadeId !== undefined) { update.variedade_id = variedadeId; } @@ -453,69 +453,96 @@ function alteracaoCuradorouOperador(request, response, transaction) { const update = {}; const nomePopular = body?.principal?.nome_popular; - if (nomePopular) update.nomes_populares = nomePopular; + if (nomePopular !== undefined) update.nomes_populares = nomePopular; + const entidadeId = body?.principal?.entidade_id; - if (entidadeId) update.entidade_id = entidadeId; + if (entidadeId !== undefined) update.entidade_id = entidadeId; + const numeroColeta = body?.principal?.numero_coleta; - if (numeroColeta) update.numero_coleta = numeroColeta; + if (numeroColeta !== undefined) update.numero_coleta = numeroColeta; + const dataColeta = body?.principal?.data_coleta; - if (dataColeta?.dia) update.data_coleta_dia = dataColeta.dia; - if (dataColeta?.mes) update.data_coleta_mes = dataColeta.mes; - if (dataColeta?.ano) update.data_coleta_ano = dataColeta.ano; + if (dataColeta?.dia !== undefined) update.data_coleta_dia = dataColeta.dia; + if (dataColeta?.mes !== undefined) update.data_coleta_mes = dataColeta.mes; + if (dataColeta?.ano !== undefined) update.data_coleta_ano = dataColeta.ano; + const tipoId = body?.principal?.tipo_id; - if (tipoId) update.tipo_id = tipoId; + if (tipoId !== undefined) update.tipo_id = tipoId; + const { cor } = body.principal || {}; - if (cor) update.cor = cor; + if (cor !== undefined) update.cor = cor; const familiaId = body?.taxonomia?.familia_id; - if (familiaId) update.familia_id = familiaId; + if (familiaId !== undefined) update.familia_id = familiaId; + const subfamiliaId = body?.taxonomia?.sub_familia_id; - if (subfamiliaId) update.sub_familia_id = subfamiliaId; + if (subfamiliaId !== undefined) update.sub_familia_id = subfamiliaId; + const generoId = body?.taxonomia?.genero_id; - if (generoId) update.genero_id = generoId; + if (generoId !== undefined) update.genero_id = generoId; + const especieId = body?.taxonomia?.especie_id; - if (especieId) update.especie_id = especieId; + if (especieId !== undefined) update.especie_id = especieId; + const subespecieId = body?.taxonomia?.sub_especie_id; - if (subespecieId) update.sub_especie_id = subespecieId; + if (subespecieId !== undefined) update.sub_especie_id = subespecieId; + const variedadeId = body?.taxonomia?.variedade_id; - if (variedadeId) update.variedade_id = variedadeId; + if (variedadeId !== undefined) update.variedade_id = variedadeId; const latitude = body?.localidade?.latitude; - if (latitude) update.latitude = converteParaDecimal(latitude); + if (latitude !== undefined) { + update.latitude = latitude ? converteParaDecimal(latitude) : null; + } + const longitude = body?.localidade?.longitude; - if (longitude) update.longitude = converteParaDecimal(longitude); + if (longitude !== undefined) { + update.longitude = longitude ? converteParaDecimal(longitude) : null; + } + const altitude = body?.localidade?.altitude; - if (altitude) update.altitude = altitude; + if (altitude !== undefined) update.altitude = altitude; + const localColeta = body?.localidade?.local_coleta_id; - if (localColeta) update.local_coleta_id = localColeta; + if (localColeta !== undefined) update.local_coleta_id = localColeta; + const soloId = body?.paisagem?.solo_id; - if (soloId) update.solo_id = soloId; + if (soloId !== undefined) update.solo_id = soloId; + const relevoId = body?.paisagem?.relevo_id; - if (relevoId) update.relevo_id = relevoId; + if (relevoId !== undefined) update.relevo_id = relevoId; + const vegetacaoId = body?.paisagem?.vegetacao_id; - if (vegetacaoId) update.vegetacao_id = vegetacaoId; + if (vegetacaoId !== undefined) update.vegetacao_id = vegetacaoId; + const descricao = body?.paisagem?.descricao; - if (descricao) update.descricao = descricao; + if (descricao !== undefined) update.descricao = descricao; + const faseSucessionalId = body?.paisagem?.fase_sucessional_id; - if (faseSucessionalId) update.fase_sucessional_id = faseSucessionalId; + if (faseSucessionalId !== undefined) update.fase_sucessional_id = faseSucessionalId; const identificadores = body?.identificacao?.identificadores; - if (identificadores?.length) update.identificadores = identificadores; + if (identificadores !== undefined) update.identificadores = identificadores; + const dataIdentificacao = body?.identificacao?.data_identificacao; - if (dataIdentificacao?.dia) update.data_identificacao_dia = dataIdentificacao.dia; - if (dataIdentificacao?.mes) update.data_identificacao_mes = dataIdentificacao.mes; - if (dataIdentificacao?.ano) update.data_identificacao_ano = dataIdentificacao.ano; + if (dataIdentificacao?.dia !== undefined) update.data_identificacao_dia = dataIdentificacao.dia; + if (dataIdentificacao?.mes !== undefined) update.data_identificacao_mes = dataIdentificacao.mes; + if (dataIdentificacao?.ano !== undefined) update.data_identificacao_ano = dataIdentificacao.ano; const coletor = body?.coletor; - if (coletor) update.coletor_id = coletor; + if (coletor !== undefined) update.coletor_id = coletor; + const complementares = body?.coletor_complementar?.complementares; - if (complementares) update.complementares = complementares; + if (complementares !== undefined) update.complementares = complementares; + const colecoesAnexasTipo = body?.colecoes_anexas?.tipo; - if (colecoesAnexasTipo) update.colecoes_anexas_tipo = colecoesAnexasTipo; + if (colecoesAnexasTipo !== undefined) update.colecoes_anexas_tipo = colecoesAnexasTipo; + const colecoesAnexasObservacoes = body?.colecoes_anexas?.observacoes; - if (colecoesAnexasObservacoes) update.colecoes_anexas_observacoes = colecoesAnexasObservacoes; + if (colecoesAnexasObservacoes !== undefined) update.colecoes_anexas_observacoes = colecoesAnexasObservacoes; + const { observacoes } = body || {}; - if (observacoes) update.observacao = observacoes; + if (observacoes !== undefined) update.observacao = observacoes; const { tombo_id: tomboId } = request.params; diff --git a/src/database/migration/20250825162350_add_descricao_tombo.ts b/src/database/migration/20250825162350_add_descricao_tombo.ts index a0ee75b3..355cee9c 100644 --- a/src/database/migration/20250825162350_add_descricao_tombo.ts +++ b/src/database/migration/20250825162350_add_descricao_tombo.ts @@ -1,7 +1,7 @@ import { Knex } from 'knex' export async function run(knex: Knex): Promise { - await knex.schema.table('tombos', (table) => { + await knex.schema.table('tombos', table => { table.text('descricao').nullable() }) } diff --git a/src/validators/tombo-alteracao.js b/src/validators/tombo-alteracao.js index 6cc7ae53..cfca9891 100644 --- a/src/validators/tombo-alteracao.js +++ b/src/validators/tombo-alteracao.js @@ -15,7 +15,9 @@ export default { 'principal.nome_popular': { in: 'body', isString: true, - optional: true, + optional: { + options: { nullable: true }, + }, isLength: { options: [{ min: 3 }], }, @@ -38,59 +40,81 @@ export default { }, 'json.principal.tipo_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.principal.cor': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, custom: { options: validaCor, }, }, 'json.taxonomia.familia_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.taxonomia.genero_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.taxonomia.subfamilia_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.taxonomia.especie_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.taxonomia.variedade_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.taxonomia.subespecie_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.localidade.latitude': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isString: true, }, 'json.localidade.longitude': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isString: true, }, 'json.localidade.altitude': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.localidade.cidade_id': { @@ -108,40 +132,54 @@ export default { }, 'json.paisagem.solo_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.paisagem.relevo_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.paisagem.vegetacao_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.paisagem.fase_sucessional': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.paisagem.descricao': { in: 'body', isString: true, - optional: true, + optional: { + options: { nullable: true }, + }, isLength: { options: [{ min: 3 }], }, }, 'json.identificacao.identificador_id': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isInt: true, }, 'json.identificacao.data_identificacao': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, custom: { options: validaData, }, @@ -155,14 +193,18 @@ export default { }, 'json.colecoes_anexas.tipo': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, custom: { options: validaColecoesAnexas, }, }, 'json.colecoes_anexas.observacoes': { in: 'body', - optional: true, + optional: { + options: { nullable: true }, + }, isString: true, isLength: { options: [{ min: 3 }], @@ -171,7 +213,9 @@ export default { 'json.observacoes': { in: 'body', isString: true, - optional: true, + optional: { + options: { nullable: true }, + }, isLength: { options: [{ min: 3 }], },