| @@ 28-34 (lines=7) @@ | ||
| 25 | ||
| 26 | // validate user inputs |
|
| 27 | $validation = new Validation(); |
|
| 28 | if(!$validation->validate([ |
|
| 29 | 'User Name' => [$name, 'alphaNumWithSpaces|maxLen(30)'], |
|
| 30 | 'Email' => [$email, 'email|maxLen(50)'], |
|
| 31 | 'Role' => [$role, 'inArray(admin, user)']])){ |
|
| 32 | $this->errors = $validation->errors(); |
|
| 33 | return false; |
|
| 34 | } |
|
| 35 | ||
| 36 | // in $options array, add all possible values from user, and their name parameters |
|
| 37 | // then applyOptions() method will see if value is not empty, then add it to our query |
|
| @@ 99-105 (lines=7) @@ | ||
| 96 | } |
|
| 97 | ||
| 98 | $validation = new Validation(); |
|
| 99 | if(!$validation->validate([ |
|
| 100 | "Name" => [$name, "alphaNumWithSpaces|minLen(4)|maxLen(30)"], |
|
| 101 | "Password" => [$password, "minLen(6)|password"], |
|
| 102 | 'Role' => [$role, "inArray(admin, user)"]])){ |
|
| 103 | $this->errors = $validation->errors(); |
|
| 104 | return false; |
|
| 105 | } |
|
| 106 | ||
| 107 | if($password || $name || $role) { |
|
| 108 | ||
| @@ 69-75 (lines=7) @@ | ||
| 66 | // if new email === old email, this shouldn't return any errors for email, |
|
| 67 | // because they are not 'required', same for name. |
|
| 68 | $validation = new Validation(); |
|
| 69 | if(!$validation->validate([ |
|
| 70 | "Name" => [$name, "alphaNumWithSpaces|minLen(4)|maxLen(30)"], |
|
| 71 | "Password" => [$password, "minLen(6)|password"], |
|
| 72 | "Email" => [$email, "email|emailUnique|maxLen(50)|equals(".$confirmEmail.")"]])){ |
|
| 73 | $this->errors = $validation->errors(); |
|
| 74 | return false; |
|
| 75 | } |
|
| 76 | ||
| 77 | $profileUpdated = ($password || $name || $email)? true: false; |
|
| 78 | if($profileUpdated) { |
|