Skip to content

Commit

Permalink
fix(server): group creation now accepts the multi-owners filter corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
Falinor committed Feb 6, 2025
1 parent bd4695b commit c4d4ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/src/models/HousingFiltersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
} from '@zerologementvacant/models';
import { EnergyConsumptionGradesApi } from './HousingApi';
import { body, ValidationChain } from 'express-validator';
import { isArrayOf, isInteger, isString, isUUID } from '~/utils/validators';
import {
isArrayOf,
isBoolean,
isInteger,
isString,
isUUID
} from '~/utils/validators';

export interface HousingFiltersApi
extends Pick<HousingFiltersDTO, 'intercommunalities'> {
Expand Down Expand Up @@ -57,7 +63,7 @@ const validators = (property = 'filters'): ValidationChain[] => [
.optional(),
body(`${property}.ownerKinds`).custom(isArrayOf(isString)).optional(),
body(`${property}.ownerAges`).custom(isArrayOf(isString)).optional(),
body(`${property}.multiOwners`).custom(isArrayOf(isString)).optional(),
body(`${property}.multiOwners`).custom(isArrayOf(isBoolean)).optional(),
body(`${property}.beneficiaryCounts`).custom(isArrayOf(isString)).optional(),
body(`${property}.housingKinds`).custom(isArrayOf(isString)).optional(),
body(`${property}.cadastralClassificiations`)
Expand Down
4 changes: 4 additions & 0 deletions server/src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function isString(value: unknown): value is string {
return typeof value === 'string';
}

export function isBoolean(value: unknown): value is boolean {
return typeof value === 'boolean';
}

export function isCommaDelimitedString(value: unknown): value is string {
const pattern = /^[-\w]+(,[-\w]+)*$/;
return isString(value) && validator.matches(value, pattern);
Expand Down

0 comments on commit c4d4ac0

Please sign in to comment.