Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/
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
You can’t perform that action at this time.