Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Inacurate textarea maxlength error #21

Open
@RudolfFrederiksen

Description

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

{
 "schemaForm": true,
 "md-maxlength": true,
 "tv4-201": true
}

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) { return e !== '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) { return e !== '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)

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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /