Skip to content

Commit

Permalink
Fixed issue #17929: Bad code can be entered and saved in answer code (#…
Browse files Browse the repository at this point in the history
…2331)

Dev: add rules
  • Loading branch information
Shnoulle committed Apr 8, 2022
1 parent 084e7e3 commit 2655369
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions application/models/Answer.php
Expand Up @@ -78,6 +78,14 @@ public function rules()
return array(
array('qid', 'numerical', 'integerOnly' => true),
array('code', 'length', 'min' => 1, 'max' => 5),
array('code', 'required'),
// Only alphanumeric
array(
'code',
'match',
'pattern' => '/^[[:alnum:]]*$/',
'message' => gT('Answer codes may only contain alphanumeric characters.'),
),
// Unicity of key
array(
'code',
Expand Down

0 comments on commit 2655369

Please sign in to comment.