Skip to content

Commit

Permalink
Improve validation messages (CO-1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Oct 3, 2021
1 parent 17dec12 commit f4b84e6
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 24 deletions.
5 changes: 4 additions & 1 deletion app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ msgstr "Unknown search type '{0}'"
msgid "match.er.table"
msgstr "Matchgrid table %1$s does not exist"

msgid "match.er.val.email"
msgstr "Provided value does not appear to be an email address"

msgid "match.er.val.length"
msgstr "Provided value exceeds maximum length of {0}"

Expand Down Expand Up @@ -503,7 +506,7 @@ msgid "match.in.matchgrid.reconcile"
msgstr "Resolve matching records when COmanage determines the same person may be coming from multiple systems of record."

msgid "match.in.matchgrid.select"
msgstr "Select the Matchgrid you'd like to manage."
msgstr "Select the Matchgrid you would like to work with."

msgid "match.in.matchgrids.none"
msgstr "There are no matchgrids currently defined."
Expand Down
10 changes: 6 additions & 4 deletions app/src/Model/Table/ApiUsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,17 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'username',
'length',
[ 'rule' => [ 'maxLength', 128 ] ]
[ 'rule' => [ 'maxLength', 128 ],
'message' => __('match.er.val.length', [128]) ]
);
// notEmpty is old style, use notBlank
$validator->notEmptyString('username');

$validator->add(
'password',
'length',
[ 'rule' => [ 'maxLength', 80 ] ]
[ 'rule' => [ 'maxLength', 80 ],
'message' => __('match.er.val.length', [80]) ]
);
$validator->notEmptyString('password');

Expand All @@ -188,14 +190,14 @@ public function validationDefault(Validator $validator): Validator {
'content',
[ 'rule' => 'isInteger' ]
);
$validator->allowEmpty('matchgrid_id');
$validator->allowEmptyString('matchgrid_id');

$validator->add(
'system_of_record_id',
'content',
[ 'rule' => 'isInteger' ]
);
$validator->allowEmpty('system_of_record_id');
$validator->allowEmptyString('system_of_record_id');

return $validator;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Table/AttributeGroupsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'name',
'length',
[ 'rule' => [ 'maxLength', 32 ] ]
[ 'rule' => [ 'maxLength', 32 ],
'message' => __('match.er.val.length', [32]) ]
);
$validator->notEmptyString('name');

Expand Down
14 changes: 9 additions & 5 deletions app/src/Model/Table/MatchgridSettingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,30 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'referenceid_start',
'content',
[ 'rule' => [ 'range', 1, null ] ]
[ 'rule' => [ 'range', 1, PHP_INT_MAX ],
'message' => __('match.er.val.range', [1, PHP_INT_MAX]) ]
);
$validator->allowEmpty('referenceid_start');
$validator->allowEmptyString('referenceid_start');

$validator->add(
'referenceid_prefix',
'content',
[ 'rule' => [ 'maxLength', 32 ] ]
[ 'rule' => [ 'maxLength', 32 ],
'message' => __('match.er.val.length', [32]) ]
);
$validator->allowEmptyString('referenceid_prefix');

$validator->add(
'notification_email',
'length',
[ 'rule' => [ 'maxLength', 80 ] ]
[ 'rule' => [ 'maxLength', 80 ],
'message' => __('match.er.val.length', [80]) ]
);
$validator->add(
'notification_email',
'content',
[ 'rule' => 'email' ]
[ 'rule' => 'email',
'message' => __('match.er.val.email') ]
);
$validator->allowEmptyString('notification_email');

Expand Down
6 changes: 4 additions & 2 deletions app/src/Model/Table/MatchgridsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'table_name',
'length',
[ 'rule' => [ 'maxLength', 128 ] ]
[ 'rule' => [ 'maxLength', 128 ],
'message' => __('match.er.val.length', [128]) ]
);
$validator->add(
'table_name',
Expand All @@ -184,7 +185,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'description',
'length',
[ 'rule' => [ 'maxLength', 128 ] ]
[ 'rule' => [ 'maxLength', 128 ],
'message' => __('match.er.val.length', [128]) ]
);
$validator->allowEmptyString('description');

Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Table/MetaTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'upgrade_version',
'length',
[ 'rule' => [ 'maxLength', 16 ] ]
[ 'rule' => [ 'maxLength', 16 ],
'message' => __('match.er.val.length', [16]) ]
);
$validator->notEmptyString('upgrade_version');

Expand Down
5 changes: 3 additions & 2 deletions app/src/Model/Table/PermissionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'username',
'length',
[ 'rule' => [ 'maxLength', 128 ] ]
[ 'rule' => [ 'maxLength', 128 ],
'message' => __('match.er.val.length', [128]) ]
);
$validator->notEmptyString('username');

Expand All @@ -104,7 +105,7 @@ public function validationDefault(Validator $validator): Validator {
'content',
[ 'rule' => 'isInteger' ]
);
$validator->allowEmpty('matchgrid_id');
$validator->allowEmptyString('matchgrid_id');

$validator->add(
'permission',
Expand Down
6 changes: 3 additions & 3 deletions app/src/Model/Table/RuleAttributesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function validationDefault(Validator $validator): Validator {
'content',
[ 'rule' => 'isInteger' ]
);
$validator->allowEmpty('crosscheck_attribute_id');
$validator->allowEmptyString('crosscheck_attribute_id');

$validator->add(
'search_type',
Expand All @@ -132,14 +132,14 @@ public function validationDefault(Validator $validator): Validator {
'toggle',
[ 'rule' => [ 'boolean' ] ]
);
$validator->allowEmpty('required');
$validator->allowEmptyString('required');

$validator->add(
'match_empty',
'toggle',
[ 'rule' => [ 'boolean' ] ]
);
$validator->allowEmpty('match_empty');
$validator->allowEmptyString('match_empty');

return $validator;
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/Model/Table/RulesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'name',
'length',
[ 'rule' => [ 'maxLength', 32 ] ]
[ 'rule' => [ 'maxLength', 32 ],
'message' => __('match.er.val.length', [32]) ]
);
$validator->notEmptyString('name');

Expand All @@ -97,7 +98,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'description',
'length',
[ 'rule' => [ 'maxLength', 128 ] ]
[ 'rule' => [ 'maxLength', 128 ],
'message' => __('match.er.val.length', [128]) ]
);
$validator->allowEmptyString('description');

Expand Down
9 changes: 6 additions & 3 deletions app/src/Model/Table/SystemsOfRecordTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'label',
'length',
[ 'rule' => [ 'maxLength', 80 ] ]
[ 'rule' => [ 'maxLength', 80 ],
'message' => __('match.er.val.length', [80]) ]
);
$validator->notEmptyString('label');

Expand All @@ -103,12 +104,14 @@ public function validationDefault(Validator $validator): Validator {
$validator->add(
'notification_email',
'length',
[ 'rule' => [ 'maxLength', 80 ] ]
[ 'rule' => [ 'maxLength', 80 ],
'message' => __('match.er.val.length', [80]) ]
);
$validator->add(
'notification_email',
'content',
[ 'rule' => 'email' ]
[ 'rule' => 'email',
'message' => __('match.er.val.email') ]
);
$validator->allowEmptyString('notification_email');

Expand Down

0 comments on commit f4b84e6

Please sign in to comment.