Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utils index #351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export default {
In the message body, any text wrapped in single braces will be replaced with their appropriate values that were passed in as options to the validator. For example:

```js
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
// validators/custom.js
export default function validateIsOne(options) {
return (key, newValue, oldValue, changes, content) => {
Expand Down
6 changes: 4 additions & 2 deletions addon/utils/get-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { A as emberArray } from '@ember/array';

import { isPresent } from '@ember/utils';
import config from 'ember-get-config';
import defaultMessages from 'ember-changeset-validations/utils/messages';
import withDefaults from 'ember-changeset-validations/utils/with-defaults';
import {
defaultMessages,
withDefaults,
} from 'ember-changeset-validations/utils';

const { keys } = Object;
const moduleName = `${config.modulePrefix}/validations/messages`;
Expand Down
7 changes: 7 additions & 0 deletions addon/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { default as getMessages } from './get-messages';
export { default as handleMultipleValidations } from './handle-multiple-validations';
export { default as defaultMessages } from './messages';
export { default as toDate } from './to-date';
export { default as buildMessage } from './validation-errors';
export { default as withDefaults } from './with-defaults';
export { default as wrapInArray } from './wrap';
2 changes: 1 addition & 1 deletion addon/utils/validation-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { get } from '@ember/object';

import { assert } from '@ember/debug';
import config from 'ember-get-config';
import getMessages from 'ember-changeset-validations/utils/get-messages';
import { getMessages } from 'ember-changeset-validations/utils';

export default function buildMessage(key, result) {
let returnsRaw = config['changeset-validations']?.rawOutput || false;
Expand Down
2 changes: 1 addition & 1 deletion addon/validators/confirmation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import evValidateConfirmation from 'ember-validators/confirmation';

export default function validateConfirmation(options = {}) {
Expand Down
8 changes: 5 additions & 3 deletions addon/validators/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import withDefaults from 'ember-changeset-validations/utils/with-defaults';
import toDate from 'ember-changeset-validations/utils/to-date';
import {
buildMessage,
withDefaults,
toDate,
} from 'ember-changeset-validations/utils';

const errorFormat = 'MMM Do, YYYY';

Expand Down
2 changes: 1 addition & 1 deletion addon/validators/exclusion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import evValidateExclusion from 'ember-validators/exclusion';

export default function validateExclusion(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion addon/validators/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isEmpty } from '@ember/utils';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import evValidateFormat from 'ember-validators/format';

export default function validateFormat(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion addon/validators/inclusion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import evValidateInclusion from 'ember-validators/inclusion';

export default function validateInclusion(options = {}) {
Expand Down
3 changes: 1 addition & 2 deletions addon/validators/length.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import withDefaults from 'ember-changeset-validations/utils/with-defaults';
import { buildMessage, withDefaults } from 'ember-changeset-validations/utils';
import evValidateLength from 'ember-validators/length';

export default function validateLength(options = {}) {
Expand Down
3 changes: 1 addition & 2 deletions addon/validators/number.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import withDefaults from 'ember-changeset-validations/utils/with-defaults';
import { buildMessage, withDefaults } from 'ember-changeset-validations/utils';
import evValidateNumber from 'ember-validators/number';

export default function validateNumber(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion addon/validators/presence.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import evValidatePresence from 'ember-validators/presence';
import { get } from '@ember/object';

Expand Down
6 changes: 4 additions & 2 deletions tests/unit/utils/get-messages-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import getMessages from 'ember-changeset-validations/utils/get-messages';
import defaultMessages from 'ember-changeset-validations/utils/messages';
import {
getMessages,
defaultMessages,
} from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Utility | get messages', function () {
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/utils/validation-errors-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import getMessages from 'ember-changeset-validations/utils/get-messages';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { getMessages, buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';
import config from 'ember-get-config';

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/confirmation-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateConfirmation from 'ember-changeset-validations/validators/confirmation';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | confirmation', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/date-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateDate from 'ember-changeset-validations/validators/date';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | date', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/exclusion-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateExclusion from 'ember-changeset-validations/validators/exclusion';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | exclusion', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/format-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateFormat from 'ember-changeset-validations/validators/format';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | format', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/inclusion-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateInclusion from 'ember-changeset-validations/validators/inclusion';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | inclusion', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/length-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateLength from 'ember-changeset-validations/validators/length';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | length', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/number-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validateNumber from 'ember-changeset-validations/validators/number';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | number', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/presence-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validatePresence from 'ember-changeset-validations/validators/presence';
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { buildMessage } from 'ember-changeset-validations/utils';
import { module, test } from 'qunit';

module('Unit | Validator | presence', function () {
Expand Down