You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we remove some characters until we reach the limit, 200 characters in my example.
The field remains invalid.
Proposition :
I think the problem comes from a remaining schemaForm error set by angular-schema-form.
I looked at its code and I saw two interesting lines used for validation :
// Any error and we're out of here!return!Object.keys(ngModel.$error).some(function(e){returne!=='schemaForm';});
// In Angular 1.3 we use one $validator to stop the model value from getting updated.// this means that we always end up with a 'schemaForm' error.errors=errors.filter(function(e){returne!=='schemaForm';});
Changing e !== 'schemaForm'; by error.indexOf('tv4-') === 0 fixed the problem.
Basically if we don't have an error from tv4 validation, we ignore it.
(It also fixes an error on textarea error messages because md-maxlength error is also ignored. I'll have a PR for this soon)
@RudolfFrederiksen I don't know many others using the Material Design decorator yet, still needs a lot of work, but frankly starting to wonder if most of that effort would be better spent on ng2 and Angular Material 2.
I would love any help/suggestions/PRs you can provide! It is hard to try to run so many repos in my spare time!
@RudolfFrederiksen spot on with your evaluation, but I can't change the behaviour in that file without breaking the bootstrap decorator also!! So I have to find a middleground.
The following change will also fix the issue with reduced impact, but I don't like it as it would require more work for every custom decorator to not cause the same issue with any other validation. .filter(function(k) { return k.indexOf('tv4-') === 0 || k.indexOf('md-') === 0; }) in schemaValidate.js#49
I created an exemple to reproduce the behavior.
http://codepen.io/anon/pen/RRVQpv?editors=1010
If the input overextends the limit we have three errors
If we remove some characters until we reach the limit, 200 characters in my example.
The field remains invalid.
Proposition :
I think the problem comes from a remaining
schemaForm
error set by angular-schema-form.I looked at its code and I saw two interesting lines used for validation :
Changing
e !== 'schemaForm';
byerror.indexOf('tv4-') === 0
fixed the problem.Basically if we don't have an error from tv4 validation, we ignore it.
(It also fixes an error on textarea error messages because
md-maxlength
error is also ignored. I'll have a PR for this soon)However I guess it breaks any custom validation --> https://github.com/json-schema-form/angular-schema-form/blob/development/docs/index.md#custom-validation
Does anyone have a better fix idea for this problem ?
The text was updated successfully, but these errors were encountered: