Giter Club home page Giter Club logo

ember-model-validator's Issues

how can i add observer to validationErrors

I have a property observing model-validator mixin property validationErrors but this is not observing the changes done in model values which are already validated. So it needs an explicit call to validate() method to update the error values in the form. Please guide us how to handle this here.

Missing `Acceptance` validator.

These values: '1', 1, and true should be the acceptable values. But the user can specify it as well with the accept option.

Can't setup ember-model-validator

Hi,
I can't get the model inside the router,
I am getting an error:
TypeError: fakeModel is undefined
or
TypeError: fakeModel.validate is not a function

also I am using ember-mirage as a single mock server.

Internationalization support (i18n)?

Hi

Is there a way to add i18n support for the default error messages (like "can't be blank"). Especially if it would work with ember-i18n :) ?

An in-range update of ember-cli is breaking the build 🚨

The devDependency ember-cli was updated from 3.15.1 to 3.15.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v3.15.2

Blueprint Changes

Changelog

Thank you to all who took the time to contribute!

Commits

The new version differs by 9 commits.

  • e17502b 3.15.2
  • 4f1a5bb Add v3.15.2 to CHANGELOG.md.
  • 9e904a9 Avoid errors when ui is not present and a warning will be emi… (#9014)
  • e164076 Supply a more universal .ui
  • 972b3a0 Allow failure of Node 8 CI jobs. (#9015)
  • c89428a Allow failure of Node 8 CI jobs.
  • dc95c25 fix named UMD imports (#8924)
  • bc6d511 allow importing named UMD files
  • 98d3928 remove amd-shim duplication

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ember-template-lint is breaking the build 🚨

The devDependency ember-template-lint was updated from 1.5.2 to 1.5.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-template-lint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for Release 1.5.3

πŸ› Bug Fix

  • #805 Update no-action-modifiers and no-element-event-actions rules to suggest using the on modifier (@bmish)
  • #803 Add 'octane' config to export list so it can be used in .template-lintrc.js (@pgengler)

Committers: 3

Commits

The new version differs by 11 commits.

  • e75fa8e Release 1.5.3
  • cf82a30 Merge pull request #805 from bmish/on-recommendation
  • 8266a43 fix: update no-action-modifiers and no-element-event-actions rules to suggest using the on modifier
  • 978df8d Add yarn lint script which calls yarn lint:js (#806)
  • 8575c86 build(deps-dev): bump eslint-config-prettier from 6.0.0 to 6.1.0
  • 9d86807 build(deps-dev): bump eslint from 6.1.0 to 6.2.0
  • 169cc09 Add yarn lint script which calls yarn lint:js.
  • 2e265db build(deps): bump @glimmer/compiler from 0.41.4 to 0.42.0 (#802)
  • fd7275a Add 'octane' config to export list so it can be found (#803)
  • 3ff1cfb Add 'octane' config to export list so it can be found (fixes #799)
  • 440ea99 build(deps): bump @glimmer/compiler from 0.41.4 to 0.42.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Ember Data 2.1 compatibility with belongsTo?

Hey!

I'm working with ember-model-validator and EmberData 2.1 and I'm having an issue validating a belongsTo relationship. I'm using version 1.1.0 of ember-model-validator

I've create my model like the following

import DS from 'ember-data';
import Ember from 'ember';
import Validator from 'weldnote/mixins/model-validator';

const { computed, isEmpty, inject } = Ember;
const { belongsTo } = DS;

export default DS.Model.extend(Validator, {
  i18n: inject.service(),
  code: belongsTo('industry-code', { async: false }),

  validations: {
    code: {
      presence: true
    }
  }

});

When I call validate() the code is considered to be empty (but it's not).
I've managed to debug the issue to the following:

//model-validator.js
_validatePresence: function _validatePresence(property, validation) {
      var propertyValue = this.get(property);
      // If the property is an async relationship.
      if (this._modelRelations() && !Ember['default'].isBlank(this._modelRelations()[property])) {
        propertyValue = this.get(property + '.content'); // Here is the problem
      }
      if (Ember['default'].isBlank(propertyValue)) {
        this.set('isValidNow', false);
        this._addToErrors(property, validation.presence, Messages['default'].presenceMessage);
      }
    },

If I console.log propertyValue, right before the this.get(property + .content') I get the following
Class {store: Class, container: Container, _internalModel: ember$data$lib$system$model$internal$model$$InternalModel, isError: false, adapterError: (...)

But the this.get(property + '.content') returns undefined.... was it this way with older versions of Ember Data (I'm guessing that's my problem).

I've been dealing with this through custom validations, but it's kind of annoying to always do this:

validations: {
    code: {
      custom: {
        validation(key, value, model) {
          let id = model.get('code.id');
          return !isEmpty(id);
        }, message(key, value) {
          let translation = value.translate('edit-view.attributes.required');
          return translation;
        }
      }
    }

Thanks a lot for the project. It's been very helpful

An in-range update of ember-ajax is breaking the build 🚨

The devDependency ember-ajax was updated from 3.1.2 to 3.1.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-ajax is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 3 commits.

  • 430d11c chore(release): 3.1.4
  • ba9a87d test: add test case around relative URL conversion
  • daf8319 Revert "fix: don't append leading '/' when building url"

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ember-cli-htmlbars-inline-precompile is breaking the build 🚨

The devDependency ember-cli-htmlbars-inline-precompile was updated from 3.0.0 to 3.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-cli-htmlbars-inline-precompile is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for Release 3.0.1

πŸ“ Documentation

🏠 Internal

  • #321 Re-roll yarn.lock to avoid errors with yarn 1.19.0 (@rwjblue)

Committers: 3

Commits

The new version differs by 22 commits.

  • 0a33678 Release 3.0.1
  • 2517d5d Merge pull request #320 from rwjblue/deprecate-and-noop
  • d3a4f4a Deprecate ember-cli-htmlbars-inline-precompiler.
  • a6f25ed Re-roll yarn.lock (#321)
  • 0eced26 Re-roll yarn.lock
  • ae928fe Bump ember-cli-babel from 7.11.0 to 7.11.1
  • 3b758a0 Bump ember-resolver from 5.2.1 to 5.3.0
  • c28a548 Fix import in README example (#305)
  • fc2d80b Fix import in README example
  • 3937089 Bump release-it from 12.4.0 to 12.4.1
  • 1307f86 Bump release-it from 12.3.6 to 12.4.0
  • 36d663e Bump eslint from 6.3.0 to 6.4.0
  • f897fb0 Bump babel-plugin-htmlbars-inline-precompile from 2.0.0 to 2.1.0
  • a66feba Merge pull request #299 from ember-cli/rwjblue-patch-1
  • 93f776b Remove problematic Chrome flags

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Doesn't validate belongsTo async relation

I have the following model

import DS from 'ember-data';
import Validator from '../mixins/model-validator';

var attr = DS.attr;

export default DS.Model.extend(Validator, {
  plan: DS.belongsTo('plan', {async: true}),
  validations: {
    plan: {
      presence: {
        message: 'Please select a plan'
      }
    }
  }
});

Then when I'm trying to validate a model trying to test the behavior when the validation fail, the validation pass, but if I delete the {async: true} the validations doesn't pass (as expected)

Emtpy value as invalid property

HI,
I noticed that if I have:

logoUrl: {
  URL:true,
},

It required from me value cuz empty string or null is always invalid. Is there an option for make any empty string or null always valid?

Issues when dealing with ember data states

in https://github.com/esbanarango/ember-model-validator/blob/master/addon/mixins/model-validator.js#L38

you are making a transition to the state updated.uncommitted and that set model properties to isNew == false and isDirty == true breaking the API like this: https://gist.github.com/sescobb27/5becc19ba451a18f5e15

a workaround to fix that problem is this, but it isn't generic for all situations.

if (!order.get('id')) {
  if (order.get('currentState.stateName') === 'root.loaded.updated.uncommitted') {
    order.transitionTo('loaded.created.uncommitted');
  }
  return order.save().then(deferred.resolve);
}

I think you should save the previous state of the model, and when the model is valid again reset that state

Document how to use the error-list in a template

I have set out to give ember-model-validator a serious try-out. It would be very helpful for me, if the documentation included an example (best practice) about how to use the error-list in a template.

For instance, look at the example at http://esbanarango.github.io/ember-model-validator/#/validators/length.

image

Here, it is possible to trigger several errors at the same time - great!

How do you relate errors for a specific model attribute to the field displaying this attribute? Are you using computed properties**?**

How do you make the error-messages immediately disappear from display and error-list, when starting to type something into a specific error-prone field, while all other errors keeps existing in the error-list and keeps being displayed**?**

An in-range update of ember-cli-babel is breaking the build 🚨

The dependency ember-cli-babel was updated from 7.13.0 to 7.13.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-cli-babel is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for Release 7.13.1

πŸ› Bug Fix

  • #311 Include decorator and class field plugins after TypeScript, if present (@dfreeman)

πŸ“ Documentation

Committers: 2

Commits

The new version differs by 5 commits.

  • a72f8b0 Release 7.13.1
  • 0d4dcc3 Include decorator and class field plugins after TypeScript, if p… (#311)
  • e08b59d Include decorator and class field plugins after TypeScript, if present
  • bc0dee4 README: Update an outdated link (#309)
  • 3f6e108 README: Update an outdated link

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

allow blank = true for numericality

numericality: {
onlyInteger: true,
allowBlank: true
}

Is there a reason why Ember.isBlank() is being used instead of Ember.isEmpty()?
For the above validation, x = ' ' validates as true, which is expected using isBlank. Coupled with an onlyInteger validation, this doesn't quite make sense.

An in-range update of sass is breaking the build 🚨

The devDependency sass was updated from 1.14.2 to 1.14.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

sass is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for Dart Sass 1.14.3

To install Dart Sass 1.14.3, download one of the packages above and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Treat :before, :after, :first-line, and :first-letter as pseudo-elements for the purposes of @extend.

  • When running in compressed mode, remove spaces around combinators in complex selectors, so a selector like a > b is output as a>b.

  • Properly indicate the source span for errors involving binary operation expressions whose operands are parenthesized.

See the full changelog for changes in earlier releases.

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Length : different messages for "too long" and "too short"

Hello there!
First, let me thank you for this very good addon!

Concerning error messages for the length constraint, is there a way to have different messages for minimum and maximum?
Something like this would be great:

length: {
    minimum: {
        value: 3,
        message: 'form.errors.tooShort'
    }
}

Is there something similar to a conditional validation?

I need to validate a field only if another attribute has an specific value and I don't know if the library has this option.

i.e. something like this:

validations: {
  images: {
    presence: true,
    validateIf: function () { return 'gallery' === this.get('type'); }
  }
}

I know I can do it with customValidators so I can solve it that way right but it feels better this way because I can reuse the base validations of the library. Does this exists? If not, I can check the code and add it with a PR.

Non-async relations are not validated correctly

Validations for related models are not run when the relationship is defined like DS.hasMany('related-model', {async: false})

I believe this is a regression introduced in this commit. I think in this case the related objects are not wrapped in a proxy so the content property is undefined.

I am currently using ember-data 2.8.1

Validation with inherit

Hi,

I have a model 'property' and 'flat'.
Flat inherits from property, but when i declare validations in both, only 'Flat' validators show, because they are rewritten.
How can I use validations from the parent in the child class?

DEPRECATION : Ember.String.fmt is deprecated use ES6 template strings instead

Using Ember 2.0.0 with Ember Data 2.1.0 and ember-model-validator I get a warning when validating numericality.

numericality: {
  allowBlank: true,
  greaterThanOrEqualTo: 0,
  lessThanOrEqualTo: 30
}
DEPRECATION: Ember.String.fmt is deprecated, use ES6 template strings instead. [deprecation id: ember-string-utils.fmt] See https://babeljs.io/docs/learn-es6/#template-strings for more details.
        at Object.fmt (http://localhost:4200/assets/vendor.js:44511:29)
        at _validateNumericality (http://localhost:4200/assets/vendor.js:167958:88)

In these lines is where the situation occurs.

Improve Numericality validator.

This validator should accept the same options as the Active Record Numericality validator.

  • only_integer
  • greater_than - Specifies the value must be greater than the supplied value. The default error message for this option is "must be greater than %{count}".
  • greater_than_or_equal_to - Specifies the value must be greater than or equal to the supplied value. The default error message for this option is "must be greater than or equal to %{count}".
  • equal_to - Specifies the value must be equal to the supplied value. The default error message for this option is "must be equal to %{count}".
  • less_than - Specifies the value must be less than the supplied value. The default error message for this option is "must be less than %{count}".
  • less_than_or_equal_to - Specifies the value must be less than or equal the supplied value. The default error message for this option is "must be less than or equal to %{count}".
  • odd - Specifies the value must be an odd number if set to true. The default error message for this option is "must be odd".
  • even - Specifies the value must be an even number if set to true. The default error message for this option is "must be even".

An in-range update of ember-cli-inject-live-reload is breaking the build 🚨

The devDependency ember-cli-inject-live-reload was updated from 1.8.2 to 1.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-cli-inject-live-reload is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 9 commits.

  • 60b2ba2 1.10.0
  • 415935b Add yarn.lock.
  • 542a2a0 Migrate to lerna-changelog + add 1.10.0 to changelog.
  • a21fd1d Merge pull request #55 from SparshithNR/path-fix
  • f6d8238 Provide backward compatibility.
  • ab29353 Pass path as argument to livereload.js
  • 68c237e release v1.9.0 πŸŽ‰
  • 2e88996 Merge pull request #54 from SparshithNR/test-refactor
  • fcd41eb Refactoring and Tests

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-ember is breaking the build 🚨

The devDependency eslint-plugin-ember was updated from 6.9.1 to 6.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-ember is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.10.0

πŸš€ Enhancement

  • #473 Add new no-incorrect-calls-with-inline-anonymous-functions rule (@raycohen)

πŸ› Bug Fix

  • #476 Add allowDynamicKeys option (default true) to require-computed-property-dependencies rule (@bmish)

Committers: 2

Commits

The new version differs by 7 commits.

  • 590cf98 v6.10.0
  • 46502cf Update CHANGELOG
  • 2e0469e Merge pull request #473 from raycohen/no-inline-anonymous-functions-to-schedule-once
  • 434b44d Merge pull request #476 from bmish/require-computed-property-dependencies-allowDynamicKeys-option
  • 5a9a0fe Add new no-incorrect-calls-with-inline-anonymous-functions rule
  • 55537f6 build(deps): bump ember-rfc176-data from 0.3.10 to 0.3.11 (#478)
  • 2733279 fix: add allowDynamicKeys option (default true) to require-computed-property-dependencies rule

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

ember model validator breaks on ember-data 1.0.0-beta.19.1

in store.recordWasInvalid(this, errors); throws an error Uncaught TypeError: internalModel.adapterDidInvalidate is not a function.

reading the source code of ember-data I found this

// ===== InternalModel
// FOR USE DURING COMMIT PROCESS
/**
  @method adapterDidInvalidate
  @private
*/
adapterDidInvalidate: function (errors) {
  var recordErrors = this.getErrors();
  ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(errors), function (key) {
    recordErrors.add(key, errors[key]);
  });
  this._saveWasRejected();
}
// ===== InternalModel

/**
  This method is called once the promise returned by an
  adapter's `createRecord`, `updateRecord` or `deleteRecord`
  is rejected with a `DS.InvalidError`.
   @method recordWasInvalid
  @private
  @param {InternalModel} internalModel
  @param {Object} errors
*/
recordWasInvalid: function (internalModel, errors) {
  internalModel.adapterDidInvalidate(errors);
}

I think you should not call that method manually, instead make something like this: https://github.com/dockyard/ember-validations/blob/master/addon/validators/local/inclusion.js#L23

Add priority errors message

First, thanks for your library it help me a lot.

Second, is there a way to prioritize errors message. For example, i have a too short message and a required message to show.

I would like to show "Requiredt" when its empty, not both. And if it too short, only "Too short".

Thanks man !

An in-range update of ember-cli-htmlbars is breaking the build 🚨

The devDependency ember-cli-htmlbars was updated from 3.0.0 to 3.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ember-cli-htmlbars is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

numericality validator assumes presence

If I put a numericality validator on one of my nullable number fields, validation will fail if input is blank. The validator should not assume the behavior of the presence validator; presence should be specified separately.

We have an API that uses a `locale` property

There are a bunch of pre-existing code that uses the locale property of the model:

// my-model
export default Model.extend(Validator, {
  locale: attr('string'),
  ...
})

This conflicts with the locale property defined here: https://github.com/esbanarango/ember-model-validator/blob/master/addon/mixins/model-validator.js#L31-L38

There are obvious workarounds:

  • monkey-patch Validator
  • use myLocale: attr('string', { key: 'locale' }) and update all existing code

In general, Ember addons tend to be very aggressive with claiming keys in users' namespaces (see emberjs/data#973), so this code is idiomatic.

But what's the suggested workaround?

Also posting so that anyone else with the problem can find it (and a solution, if there is one).

cc @rwwagner90 @jblakeman

A Subclass' validations override the superclass' validations

To reproduce:

on super class:

  • validate one field

on sub class:

  • validate a different field

test:

  • have an instance of the sub class
  • do something that you would expect to cause both validations to fail
  • there is only an error for the subclass's validation, and not the superclass

ember-model-validator does not show anything

In the model I did like this:

import Ember from 'ember';

import Validator from 'ember-model-validator/mixins/model-validator';

export default Model.extend(Validator,{
  login: attr(),

  password: attr(),

 validations: {
    login: {
       presence: true
    },  
   password: {
     presence: true     
   }
  },

});

In the template.hbs I do something like this:

        <table>
             <tbody>
                 <tr>               
                    <td>{{input value=login}}</td>         
                    <td>{{input value=password}}</td>       
                </tr>
             </tbody>
         </table>

It does not show anything when I try to submit empty login or password.

Do I need to do something else ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.