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
{{ message }}
Repository navigation
bug: Angular min/max validation not working on ion-input #23480
#20163 and #18240 reported this previously but at that time the issues were closed because it was a bug in Angular. Now Angular has fixed their bug in version 12 (angular/angular#39063) but the validation is still not working for ion-inputs. If I change ion-input to a input then the validation works.
One option here is to extend the MaxValidator and MinValidator directives with selectors that allow for ion-input, but I am trying to understand why these new validators are restricted to only input while other validators such as maxlength are not, despite maxlength only being available for input and textarea. I reached out to the Angular team for clarification, so hopefully we should have an idea as to how to solve this issue soon.
I touched based with the Angular team and it looks like this change was done so as to not conflict with 3rd party libraries that have their own max/min validators. I think extending the validators with a custom selector for ion-input seems like to best option here.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
liamdebeasi commentedon Jun 22, 2021
Thanks for the issue. The problem here appears to be that the min and max validators in Angular look specifically for
input[type=number], but we need the validators to seeion-input[type=number], so the max/min validators are never setup on theion-inputcomponents in your test app: https://github.com/angular/angular/blob/master/packages/forms/src/directives/validators.ts#L168Other validators, such as https://github.com/angular/angular/blob/master/packages/forms/src/directives/validators.ts#L619, do not have this restriction as they only look for the attributes, allowing them to pick up
ion-input.One option here is to extend the
MaxValidatorandMinValidatordirectives with selectors that allow forion-input, but I am trying to understand why these new validators are restricted to onlyinputwhile other validators such asmaxlengthare not, despitemaxlengthonly being available for input and textarea. I reached out to the Angular team for clarification, so hopefully we should have an idea as to how to solve this issue soon.liamdebeasi commentedon Jul 6, 2021
I touched based with the Angular team and it looks like this change was done so as to not conflict with 3rd party libraries that have their own max/min validators. I think extending the validators with a custom selector for
ion-inputseems like to best option here.JulienLecoq commentedon Jan 21, 2023
Any news about this issue?
fix(angular): min/max validator for ion-input type number (#27993)
ionitron-bot commentedon Sep 17, 2023
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.