fix: antennas validation (#11469)
This commit is contained in:
parent
49fc4cce3c
commit
f664f941a2
|
@ -85,8 +85,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
if ((ps.keywords.length === 0) || ps.keywords[0].every(x => x === '')) {
|
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||||
throw new Error('invalid param');
|
throw new Error('either keywords or excludeKeywords is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentAntennasCount = await this.antennasRepository.countBy({
|
const currentAntennasCount = await this.antennasRepository.countBy({
|
||||||
|
|
|
@ -82,6 +82,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||||
|
throw new Error('either keywords or excludeKeywords is required.');
|
||||||
|
}
|
||||||
// Fetch the antenna
|
// Fetch the antenna
|
||||||
const antenna = await this.antennasRepository.findOneBy({
|
const antenna = await this.antennasRepository.findOneBy({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
|
|
Loading…
Reference in New Issue