Mongoose tries to validate hashed password on pre save

When a user tries to create an account on pre('save' function()) (because I thought that pre save runs after validation) I hash his password in order to store the hashed version to the database. So when I create a new user with postman the correct data is being added to database (email and hashed password). In order to put in the database the hashed password I use the pre save hook

userSchema.pre('save', async function(next) {
    let user = this;
    if (user.isModified('password')) {
        user.password = await bcrypt.hash(user.password, 8)
    }
    next();
})

The issue is that although the database is filled correctly I get a validation error because mongoose tries to validate my hashed password for some reason that I do not understand.

const userSchema = new mongoose.Schema({ 
    email: {
        type: String,
        required: true,
        trim: true,
        lowercase: true,
        unique: true,
        match: [/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/, 'Invalid email address']
    },
    password: {
        type: String,
        required: true,
        trim: true,
        match: [/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,20}$/, 'password must contain at least 1 lowercase letter, 1 uppercase letter, 1 digit and have 8-20 characters']
    },
    tokens: [{
        token: {
            type: String,
            required: true
        }
    }]
});

I was very sure that the pre('save' function()) runs after the validation occurs and also since there is a validation error why is the database filled correctly?

enter image description here

enter image description here

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum