Last active
July 31, 2018 09:26
-
-
Save theotherdy/f65d6fc014da85dc025db1b3ee07a5be to your computer and use it in GitHub Desktop.
Validation in update (store would be the same, but without unique ignore) - see: https://learntech.imsu.ox.ac.uk/blog/angular-reactive-form-custom-validator-for-orcid/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update(Request $request, $id) | |
{ | |
$messages = [ | |
..., | |
'orcid.unique' => 'This ORCID ID is already in use in our database', | |
'orcid.regex' => 'The ORCID ID is in the format https://orcid.org/xxxx-xxxx-xxxx-xxxx', | |
..., | |
]; | |
//require more complex validation style to have unique ignore rule for ORCID | |
Validator::make($request->all(), [ //request->all() returns array required by Validator::make | |
..., | |
'orcid' => [ | |
Rule::unique('users')->ignore($id), | |
'regex:/^http[s]?:\/\/orcid.org\/(\d{4})-(\d{4})-(\d{4})-(\d{3}[0-9X])$/', //from: https://github.com/pkp/pkp-lib/blob/master/classes/validation/ValidatorORCID.inc.php | |
new Orcid | |
], | |
..., | |
],$messages)->validate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment