Skip to content

Commit

Permalink
Merge branch '39-uganda-template' into 31-dob
Browse files Browse the repository at this point in the history
  • Loading branch information
kennsippell authored Jan 31, 2024
2 parents 11f12e5 + 9623101 commit 57934b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/config/chis-ug/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"friendly_name": "VHT Area Name",
"property_name": "name",
"type": "name",
"parameter": ["\\sArea", "\\s(village)"],
"parameter": ["\\sArea", "\\s\\(.*\\)"],
"required": true
},

Expand Down
2 changes: 1 addition & 1 deletion src/config/chis-ug/gross.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default async function mutate(payload: PlacePayload): Promise<PlacePayloa
if (payload.contact_type === 'health_center') {
// during replacement, the name is optional
if (payload.name) {
payload.name += ' Area (village)';
payload.name += ` Area (${payload.village})`;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/validator-gender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export default class ValidatorGender implements IValidator {
}

get defaultError(): string {
return `Must be either 'Male' or 'Female'`;
return `Must be either 'male' or 'female'`;
}

private parseGenders(input: string): { gender: string; isValid: boolean } {
const isFemale = input?.match(/[fw]/i);
const isMale = input?.match(/m(?<!fem|wom)/i);
const isValid = (!!isFemale || !!isMale) && !(isFemale && isMale);
const gender = isMale ? 'Male' : 'Female';
const gender = isMale ? 'male' : 'female';
return { isValid, gender };
}
}
14 changes: 7 additions & 7 deletions test/lib/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ const scenarios: Scenario[] = [
{ type: 'name', prop: 'Sam\'s CHU', propertyParameter: ['CHU', 'Comm Unit'], isValid: true, altered: 'Sam\'s' },
{ type: 'name', prop: 'Jonathan M.Barasa', isValid: true, altered: 'Jonathan M Barasa' },

{ type: 'gender', prop: 'Man', isValid: true, altered: 'Male' },
{ type: 'gender', prop: 'male', isValid: true, altered: 'Male' },
{ type: 'gender', prop: 'F', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'Female', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'Woman', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'X', isValid: false, error: 'Male' },

{ type: 'dob', prop: '', isValid: false },
{ type: 'dob', prop: '2016/05/25', isValid: false },
{ type: 'dob', prop: 'May 25, 2016', isValid: false },
{ type: 'dob', prop: '2030-05-25', isValid: false },
{ type: 'dob', prop: '2016-05-25', isValid: true, altered: '2016-05-25' },
{ type: 'dob', prop: ' 20 16- 05- 25 ', isValid: true, altered: '2016-05-25' },

{ type: 'gender', prop: 'Man', isValid: true, altered: 'male' },
{ type: 'gender', prop: 'male', isValid: true, altered: 'male' },
{ type: 'gender', prop: 'F', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'Female', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'Woman', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'X', isValid: false, error: 'male' },
];

describe('lib/validation', () => {
Expand Down

0 comments on commit 57934b9

Please sign in to comment.