angular: Request to have validation errors named in camelCase opposed to all lowercase

See the code below: https://github.com/angular/angular/blob/38cb526f60f910ddbdb532639a03b57d9da378c5/modules/angular2/src/common/forms/validators.ts#L60

If I use the minLength validator on a control, the error I check for is minlength. It’s just a bit inconsistent, so that’s why I’m suggesting this change.

Thoughts?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 27 (12 by maintainers)

Most upvoted comments

@GeorgeKnap That was talking about validator (function) name, which is minLength. And the error property name used in minLength validator has always been minlength, please try read the thread again.

two years later but getting into this issue while using minLength validator.

userForm.get('password')!.hasError('minlength') works but userForm.get('password')!.hasError('minLength') doesn’t.

This has not been fixed?

angular version 5.2.4

Bump - This is still not fixed.

@kara

we’ve decided to keep the validators as “maxLength” and “minLength” to match the native property names.

That’s the opposite of what the issue is. The problem is not that they are camel cased, it’s that when trying to access them on someFormControl.errors they are NOT camel cased.

Is the Slack channel private or public? I couldn’t find anything about it.

Agreed. From a self documenting code standpoint. since I used Validators.maxLength I would expect to use control.errors?.maxLength on the html as it matches the validator I set up in code.

the magic strings problem that @ps2goat described is a great way to think about this.

Agreed. This caused me a lot of hassle.