File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,42 @@ export class UUIInputElement extends FormControlMixin(LitElement) {
134
134
` ,
135
135
] ;
136
136
137
+ /**
138
+ * This is a minimum value of the input.
139
+ * @type {number }
140
+ * @attr
141
+ * @default undefined
142
+ */
143
+ @property ( { type : Number } )
144
+ minlength ?: number ;
145
+
146
+ /**
147
+ * Minlength validation message.
148
+ * @type {boolean }
149
+ * @attr
150
+ * @default
151
+ */
152
+ @property ( { type : String , attribute : 'minlength-message' } )
153
+ minlengthMessage = 'This field need more characters' ;
154
+
155
+ /**
156
+ * This is a maximum value of the input.
157
+ * @type {number }
158
+ * @attr
159
+ * @default undefined
160
+ */
161
+ @property ( { type : Number } )
162
+ maxlength ?: number ;
163
+
164
+ /**
165
+ * Maxlength validation message.
166
+ * @type {boolean }
167
+ * @attr
168
+ * @default
169
+ */
170
+ @property ( { type : String , attribute : 'maxlength-message' } )
171
+ maxlengthMessage = 'This field exceeds the allowed amount of characters' ;
172
+
137
173
/**
138
174
* Disables the input.
139
175
* @type {boolean }
@@ -190,6 +226,17 @@ export class UUIInputElement extends FormControlMixin(LitElement) {
190
226
this . addEventListener ( 'blur' , ( ) => {
191
227
this . style . setProperty ( '--uui-show-focus-outline' , '' ) ;
192
228
} ) ;
229
+
230
+ this . addValidator (
231
+ 'tooShort' ,
232
+ ( ) => this . minlengthMessage ,
233
+ ( ) => ! ! this . minlength && ( this . _value as string ) . length < this . minlength
234
+ ) ;
235
+ this . addValidator (
236
+ 'tooLong' ,
237
+ ( ) => this . maxlengthMessage ,
238
+ ( ) => ! ! this . maxlength && ( this . _value as string ) . length > this . maxlength
239
+ ) ;
193
240
}
194
241
195
242
/**
You can’t perform that action at this time.
0 commit comments