From 99b93e55cbbbf3e865349ef3be7f105c48aec9d2 Mon Sep 17 00:00:00 2001 From: Sonu Kapoor Date: Sat, 28 Mar 2020 09:59:40 -0400 Subject: [PATCH] docs(forms): clarify the description of `minLength` and `maxLength` (#36297) Previously, it was not clear that the `minLength` and `maxLength` validators can only be used with objects that contain a `length` property. This commit clarifies this. PR Close #36297 --- packages/forms/src/validators.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/forms/src/validators.ts b/packages/forms/src/validators.ts index 51bc05f438..ccb37f76fd 100644 --- a/packages/forms/src/validators.ts +++ b/packages/forms/src/validators.ts @@ -267,7 +267,11 @@ export class Validators { * @description * Validator that requires the length of the control's value to be greater than or equal * to the provided minimum length. This validator is also provided by default if you use the - * the HTML5 `minlength` attribute. + * the HTML5 `minlength` attribute. Note that the `minLength` validator is intended to be used + * only for types that have a numeric `length` property, such as strings or arrays. The `minLength` + * validator logic is also not invoked for values when their `length` property is 0 (for example in + * case of an empty string or an empty array), to support optional controls. You can use + * the standard `required` validator if empty values should not be considered valid. * * @usageNotes * @@ -305,7 +309,8 @@ export class Validators { * @description * Validator that requires the length of the control's value to be less than or equal * to the provided maximum length. This validator is also provided by default if you use the - * the HTML5 `maxlength` attribute. + * the HTML5 `maxlength` attribute. Note that the `maxLength` validator is intended to be used + * only for types that have a numeric `length` property, such as strings or arrays. * * @usageNotes *