Skip to content

Commit 138d076

Browse files
Initial commit
1 parent 66e465b commit 138d076

9 files changed

+2948
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["env"]
3+
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.DS_Store

build.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { rollup } from 'rollup';
2+
import buble from 'rollup-plugin-buble';
3+
import resolve from 'rollup-plugin-node-resolve';
4+
import commonjs from 'rollup-plugin-commonjs';
5+
import uglify from 'uglify-js';
6+
import fs from 'fs';
7+
import path from 'path';
8+
import chalk from 'chalk';
9+
import { version } from './package.json';
10+
11+
const banner = `/**
12+
* vee-validate-laravel v${version}
13+
*/`
14+
15+
const outputFolder = path.join(__dirname, 'dist');
16+
17+
const uglifyOptions = {
18+
compress: true,
19+
mangle: true
20+
};
21+
22+
const inputOptions = {
23+
input: 'src/vee-validate-laravel.js',
24+
plugins: [
25+
resolve(),
26+
commonjs(),
27+
buble(),
28+
],
29+
};
30+
31+
const outputOptions = {
32+
format: 'umd',
33+
name: 'VeeValidateLaravel',
34+
banner: banner,
35+
};
36+
37+
async function build () {
38+
console.log(chalk.cyan('Generating main builds...'));
39+
40+
const bundle = await rollup(inputOptions);
41+
const { code } = await bundle.generate(outputOptions);
42+
43+
fs.writeFileSync(path.join(outputFolder, 'vee-validate-laravel.js'), code);
44+
console.log(chalk.green('Output File:') + ' vee-validate-laravel.js');
45+
46+
fs.writeFileSync(path.join(outputFolder, 'vee-validate-laravel.min.js'), uglify.minify(code, uglifyOptions).code);
47+
console.log(chalk.green('Output File:') + ' vee-validate-laravel.min.js');
48+
}
49+
50+
build();

dist/vee-validate-laravel.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* vee-validate-laravel v1.0.0
3+
*/
4+
(function (global, factory) {
5+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
6+
typeof define === 'function' && define.amd ? define(factory) :
7+
(global.VeeValidateLaravel = factory());
8+
}(this, (function () { 'use strict';
9+
10+
var veeValidateLaravel = {
11+
install: function install(Vue, options) {
12+
Vue.prototype.$setLaravelValidationErrorsFromResponse = function(errorResponse) {
13+
var this$1 = this;
14+
15+
// only allow this function to be run if the validator exists
16+
if (!this.hasOwnProperty('$validator')) {
17+
return;
18+
}
19+
20+
// clear errors
21+
this.$validator.errors.clear();
22+
23+
// check if errors exist
24+
if (!errorResponse.hasOwnProperty('errors')) {
25+
return;
26+
}
27+
28+
var errorFields = Object.keys(errorResponse.errors);
29+
30+
// insert laravel errors
31+
for (var i = 0; i < errorFields.length; i++) {
32+
var field = errorFields[i];
33+
34+
var errorString = errorResponse.errors[field].join(', ');
35+
this$1.$validator.errors.add(field, errorString);
36+
}
37+
};
38+
39+
if(options) {
40+
Vue.prototype.$laravelData = options;
41+
} else {
42+
Vue.prototype.$laravelData = {};
43+
}
44+
}
45+
};
46+
47+
return veeValidateLaravel;
48+
49+
})));

dist/vee-validate-laravel.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)