Skip to content

Commit

Permalink
move the core files to subfolder and export Rules closes #844
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 23, 2017
1 parent c635f18 commit 30ac26f
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 47 deletions.
23 changes: 12 additions & 11 deletions dist/vee-validate.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5430,6 +5430,16 @@ function install (_Vue, options) {
Vue.directive('validate', createDirective$1(config$$1));
}

function use (plugin, options) {
if ( options === void 0 ) options = {};

if (!isCallable(plugin)) {
return warn('The plugin must be a callable function');
}

plugin({ Validator: Validator, ErrorBag: ErrorBag, Rules: Validator.rules }, options);
}

var after = function (value, ref) {
var otherValue = ref[0];
var inclusion = ref[1];
Expand Down Expand Up @@ -6522,16 +6532,6 @@ var Rules = {
url: url
};

function use (plugin, options) {
if ( options === void 0 ) options = {};

if (!isCallable(plugin)) {
return warn('The plugin must be a callable function');
}

plugin({ Validator: Validator, ErrorBag: ErrorBag, Rules: Validator.rules }, options);
}

var normalize = function (fields) {
if (Array.isArray(fields)) {
return fields.reduce(function (prev, curr) {
Expand Down Expand Up @@ -6595,8 +6595,9 @@ var index_esm = {
mapFields: mapFields,
Validator: Validator,
ErrorBag: ErrorBag,
Rules: Rules,
version: version
};

export { install, use, mapFields, Validator, ErrorBag, version };
export { install, use, mapFields, Validator, ErrorBag, Rules, version };
export default index_esm;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/validator.js → src/core/validator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ErrorBag from './errorBag';
import Dictionary from './dictionary';
import { messages } from '../locale/en';
import { messages } from '../../locale/en';
import { isObject, isCallable, toArray, warn, createError, assign, find, isNullOrUndefined } from './utils';
import Field from './field';
import FieldBag from './fieldBag';
Expand Down
4 changes: 2 additions & 2 deletions src/directive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Generator from './generator';
import Generator from './core/generator';
import config from './config';
import { getDataAttribute, isEqual, warn, assign } from './utils';
import { getDataAttribute, isEqual, warn, assign } from './core/utils';

/**
*
Expand Down
10 changes: 6 additions & 4 deletions src/index.esm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Validator from './validator';
import install from './install';
import Rules from './rules';
import use from './use';
import ErrorBag from './errorBag';
import mapFields from './helpers';
import Rules from './rules';
import mapFields from './core/helpers';
import Validator from './core/validator';
import ErrorBag from './core/errorBag';

const version = '__VERSION__';

Expand All @@ -21,6 +21,7 @@ export {
mapFields,
Validator,
ErrorBag,
Rules,
version
};

Expand All @@ -30,5 +31,6 @@ export default {
mapFields,
Validator,
ErrorBag,
Rules,
version
};
6 changes: 3 additions & 3 deletions src/index.minimal.esm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Validator from './validator';
import Validator from './core/validator';
import install from './install';
import use from './use';
import ErrorBag from './errorBag';
import mapFields from './helpers';
import ErrorBag from './core/errorBag';
import mapFields from './core/helpers';

const version = '__VERSION__';

Expand Down
6 changes: 3 additions & 3 deletions src/index.minimal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Validator from './validator';
import install from './install';
import use from './use';
import ErrorBag from './errorBag';
import mapFields from './helpers';
import Validator from './core/validator';
import mapFields from './core/helpers';
import ErrorBag from './core/errorBag';

export default {
install,
Expand Down
4 changes: 2 additions & 2 deletions src/install.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import makeMixin from './mixin';
import Validator from './validator';
import makeDirective from './directive';
import defaultOptions from './config';
import { warn, assign } from './utils';
import Validator from './core/validator';
import { warn, assign } from './core/utils';

let Vue;

Expand Down
4 changes: 2 additions & 2 deletions src/mixin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isObject, isCallable, createProxy, createFlags } from './utils';
import Validator from './validator';
import { isObject, isCallable, createProxy, createFlags } from './core/utils';
import Validator from './core/validator';

const fakeFlags = createProxy({}, {
get (target, key) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/after.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAfter, isEqual } from 'date-fns';
import { parseDate as parse } from '../utils';
import { parseDate as parse } from '../core/utils';

export default (value, [otherValue, inclusion, format]) => {
if (typeof format === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/before.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isBefore, isEqual } from 'date-fns';
import { parseDate as parse } from '../utils';
import { parseDate as parse } from '../core/utils';

export default (value, [otherValue, inclusion, format]) => {
if (typeof format === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/date_between.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAfter, isBefore, isEqual } from 'date-fns';
import { parseDate as parse } from '../utils';
import { parseDate as parse } from '../core/utils';

export default (value, params) => {
let min;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/date_format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseDate as parse } from '../utils';
import { parseDate as parse } from '../core/utils';

export default (value, [format]) => {
return !!parse(value, format);
Expand Down
2 changes: 1 addition & 1 deletion src/rules/length.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toArray } from '../utils';
import { toArray } from '../core/utils';

/**
* @param {Array|String} value
Expand Down
6 changes: 3 additions & 3 deletions src/use.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Validator from './validator';
import ErrorBag from './errorBag';
import { warn, isCallable } from './utils';
import Validator from './core/validator';
import ErrorBag from './core/errorBag';
import { warn, isCallable } from './core/utils';

function use (plugin, options = {}) {
if (!isCallable(plugin)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/dictionary.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Dictionary from './../src/dictionary';
import Dictionary from './../src/core/dictionary';

test('does not merge if a non object is provided', () => {
const dict = new Dictionary('a string');
Expand Down
2 changes: 1 addition & 1 deletion tests/errorBag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ErrorBag from './../src/errorBag';
import ErrorBag from './../src/core/errorBag';

test('adds errors to the collection', () => {
const errors = new ErrorBag();
Expand Down
2 changes: 1 addition & 1 deletion tests/field.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Field from '../src/field';
import Field from '../src/core/field';

test('constructs a headless field with default values', () => {
const field = new Field(null, {});
Expand Down
4 changes: 2 additions & 2 deletions tests/fieldBag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FieldBag from '../src/fieldBag';
import Field from '../src/field';
import FieldBag from '../src/core/fieldBag';
import Field from '../src/core/field';

test('adds field items to the collection', () => {
const bag = new FieldBag();
Expand Down
2 changes: 1 addition & 1 deletion tests/generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Generator from '../src/generator';
import Generator from '../src/core/generator';

test('resolves the bound model', () => {
// watchable model.
Expand Down
2 changes: 1 addition & 1 deletion tests/helpersTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapFields from '../src/helpers';
import mapFields from '../src/core/helpers';

test('it maps field names from array to object of functions', () => {
const fields = mapFields(['email', 'name', 'scoped.phone']);
Expand Down
4 changes: 2 additions & 2 deletions tests/mixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue/dist/vue';
import makeMixin from '../src/mixin';
import ErrorBag from '../src/errorBag';
import FieldBag from '../src/fieldBag';
import ErrorBag from '../src/core/errorBag';
import FieldBag from '../src/core/fieldBag';
import plugin from './../src/index';

const Validator = plugin.Validator;
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../src/utils';
import * as utils from '../src/core/utils';
import * as i18Utils from '../locale/utils';

test('gets the data attribute prefixed with the plugin', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/validator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Field from './../src/field';
import Field from './../src/core/field';
import helpers from './helpers';
import plugin from './../src/index';

Expand Down

0 comments on commit 30ac26f

Please sign in to comment.