Skip to content

Commit

Permalink
Merge branch 'MDL-64010-master' of git://github.com/abgreeve/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Nov 19, 2018
2 parents c47fea4 + 347b771 commit dd2d82e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions badges/competency_form.php
Expand Up @@ -76,4 +76,19 @@ public function definition() {
}
}
}

/**
* Validate the data from the form.
*
* @param array $data form data
* @param array $files form files
* @return array An array of error messages.
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if (!empty($data['targeturl']) && !preg_match('@^https?://.+@', $data['targeturl'])) {
$errors['targeturl'] = get_string('invalidurl', 'badges');
}
return $errors;
}
}
4 changes: 4 additions & 0 deletions badges/edit_form.php
Expand Up @@ -211,6 +211,10 @@ public function validation($data, $files) {
$errors['name'] = get_string('error:duplicatename', 'badges');
}

if ($data['imageauthorurl'] && !preg_match('@^https?://.+@', $data['imageauthorurl'])) {
$errors['imageauthorurl'] = get_string('invalidurl', 'badges');
}

return $errors;
}
}
Expand Down
6 changes: 6 additions & 0 deletions badges/endorsement_form.php
Expand Up @@ -86,6 +86,12 @@ public function validation($data, $files) {
if ($data['issueremail'] && !validate_email($data['issueremail'])) {
$errors['issueremail'] = get_string('invalidemail');
}
if ($data['issuerurl'] && !preg_match('@^https?://.+@', $data['issuerurl'])) {
$errors['issuerurl'] = get_string('invalidurl', 'badges');
}
if ($data['claimid'] && !preg_match('@^https?://.+@', $data['claimid'])) {
$errors['claimid'] = get_string('invalidurl', 'badges');
}
return $errors;
}
}

0 comments on commit dd2d82e

Please sign in to comment.