How to use unique when updating users profile

if a user updates there profile and does not change the email address, a unique validator will say the email has already been taken.

How do I use unique but ask it to ignore the users own profile record?

I solved it, although it does not seem to be in the documentation for indicative

get rules() {
    const { userid } = this.ctx.request.post() //Add hidden field to form containing the userid
    return {
      email: `required|email|unique:users,email,id,${userid}`,
      username: `required|min:5|unique:users,username,id,${userid}`,
      first_name: 'required',
      last_name: 'required'
    }
  }

as an example

unique:users,username,id,1 // table, field, idcolumn, value to ignore
1 Like