Vue listen to input text length limit

<template>
  <div>
    Enter text, maximum length is 10 characters; otherwise a prompt will appear:
    <input v-model="searchText"/>
  </div>
</template>
<script>
export default {
  data() {
    return {
      searchText:""
    }
  },
  watch: {
    searchText(oldValue, newValue) {
      if (newValue.length > 10) {
        alert("Text is too long");
      }
    }
  }
};
</script>