Skip to content

Commit 3aced1b

Browse files
tarrowdeer-wmde
authored andcommitted
Allow and require audience in profile if data-hub (#906)
* only allow audience in profile if data-hub * fix and improve tests
1 parent 5a2c67e commit 3aced1b

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

app/Helper/ProfileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function validate( $profile ): \Illuminate\Validation\Validator {
1111
return Validator::make($profile, [
1212
'purpose' => 'in:data_hub,data_lab,tool_lab,test_drive,decide_later,other',
1313
'purpose_other' => 'string|required_if:purpose,other|missing_unless:purpose,other',
14-
'audience' => 'in:narrow,wide,other',
14+
'audience' => 'in:narrow,wide,other|required_if:purpose,data_hub|missing_unless:purpose,data_hub',
1515
'audience_other' => 'string|required_if:audience,other|missing_unless:audience,other',
1616
'temporality' => 'in:permanent,temporary,decide_later,other',
1717
'temporality_other' => 'string|required_if:temporality,other|missing_unless:temporality,other',

tests/Helper/ProfileValidatorTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ private function validProfileProvider() {
3232
'temporality' => 'permanent',
3333
] ],
3434
[ 'with other values' => [
35-
'purpose' => 'other',
36-
'purpose_other' => 'for fun',
35+
'purpose' => 'data_hub',
3736
'audience' => 'other',
3837
'audience_other' => 'my cat',
3938
'temporality' => 'other',
@@ -46,7 +45,12 @@ private function validProfileProvider() {
4645
private function invalidProfileProvider() {
4746
return [
4847
[ 'missing other keys' => [
49-
'purpose' => 'other',
48+
'purpose' => 'data_hub',
49+
'audience' => 'narrow',
50+
'temporality' => 'other',
51+
] ],
52+
[ 'audience key present when purpose not data_hub' => [
53+
'purpose' => 'data_lab',
5054
'audience' => 'narrow',
5155
'temporality' => 'permanent',
5256
] ],

0 commit comments

Comments
 (0)