Vue Template Validator

1.1.5 · abandoned · verified Sun Apr 19

Vue Template Validator is an archival utility designed to catch common syntax errors in Vue.js templates at compile time. It operates by analyzing template strings to identify malformed syntax. The package's last update was over 10 years ago, with its most recent official version being 1.1.5. Due to its age and lack of maintenance, it is not compatible with modern Vue.js versions (Vue 2.x, Vue 3.x, or the Composition API) and is largely superseded by contemporary build tools and linters like ESLint with `eslint-plugin-vue`. Its release cadence was sporadic and has ceased entirely. Key differentiators at the time of its development were its focus on compile-time template syntax validation, distinct from runtime form validation libraries.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `validate` function and use it to check a Vue template string for syntax errors, logging any warnings found.

const validate = require('vue-template-validator');

const templateString = `<template>
  <div v-if="isValid">
    <p>Hello World</p>
    <img src="image.jpg" />
  </div>
  <div v-else></div>
</template>

<style>
.container {
  color: blue;
}
</style>

<script>
export default {
  data() {
    return {
      isValid: true
    };
  }
};
</script>`;

const warnings = validate(templateString);

if (warnings.length > 0) {
  console.error('Template validation errors found:');
  warnings.forEach(function (msg) {
    console.error(`- ${msg}`);
  });
} else {
  console.log('Template is valid!');
}

view raw JSON →