ui5-validator icon indicating copy to clipboard operation
ui5-validator copied to clipboard

[Bug] add required to input field does not work

Open TimoStahl opened this issue 7 years ago • 3 comments

Hi,

if I add required="true" to my input field it does not work.

I thought the following input should be validated correct (after #11).

Unfortunately it does not work:

working:

<Label text="Old style" required="true" />
                              <Input value="{ 
                                  path : '/text', 
                                  type : 'sap.ui.model.type.String', 
                                  constraints : { 
                                      minLength : 3, 
                                      maxLength : 10 
                                  }
                              }"
                               />

not working:

<Label text="length and required" required="true" />
                              <Input value="{ 
                                  path : '/text2', 
                                  type : 'sap.ui.model.type.String', 
                                  constraints : { 
                                      minLength : 3, 
                                      maxLength : 10 
                                  }
                              }" 
                              required="true" />
<Label text="only required" required="true" />
                              <Input value="{ 
                                  path : '/text3'
                              }"
                               required="true" />

image

see http://plnkr.co/edit/nj3kFKSFjtkZElQMi69m?p=preview

Any suggestions?

Thanks

TimoStahl avatar Oct 29 '18 11:10 TimoStahl

Hi,

SAPUI5 framework retains the previous ValueStateText message after repeated validations. Solution would be to clear ValueStateText along with setting value state to None.

But it seems you use the old version of code and this suggestion is not valid for you.

Please check this example, where I used latest code base with my corrections: http://plnkr.co/edit/5Wxy5wzv11sGj3UQ?preview

Regards, Vladimirs

vpasedko avatar Aug 03 '20 23:08 vpasedko

Hi,

SAPUI5 framework retains the previous ValueStateText message after repeated validations. Solution would be to clear ValueStateText along with setting value state to None.

But it seems you use the old version of code and this suggestion is not valid for you.

Please check this example, where I used latest code base with my corrections: http://plnkr.co/edit/5Wxy5wzv11sGj3UQ?preview

Regards, Vladimirs

Hi @vpasedko,

I don't know if we talked of the same issue, but I confronted a bug too with the required attribute. If I don't set required to true but I add a regex contraint in search, the validation error occurs anyway.

Here is what I tested in your example code (constraint is AAA + 3 digits but field not required ): <Label text="Name" /> <Input value="{ path : '/userName', type : 'sap.ui.model.type.String', constraints : { minLength : 0, maxLength : 10, search: 'AAA[0-9]{3,}' } }"/>

juliendesprez avatar Oct 10 '20 17:10 juliendesprez

Hi, SAPUI5 framework retains the previous ValueStateText message after repeated validations. Solution would be to clear ValueStateText along with setting value state to None. But it seems you use the old version of code and this suggestion is not valid for you. Please check this example, where I used latest code base with my corrections: http://plnkr.co/edit/5Wxy5wzv11sGj3UQ?preview Regards, Vladimirs

Hi @vpasedko,

I don't know if we talked of the same issue, but I confronted a bug too with the required attribute. If I don't set required to true but I add a regex contraint in search, the validation error occurs anyway.

Here is what I tested in your example code (constraint is AAA + 3 digits but field not required ): <Label text="Name" /> <Input value="{ path : '/userName', type : 'sap.ui.model.type.String', constraints : { minLength : 0, maxLength : 10, search: 'AAA[0-9]{3,}' } }"/>

Hi,

Required field validation is an extra validation before constraints check. Validator executes constraint conditions check all the time despite "required" property set or not set. You need to adjust a regex string to something like 'AAA[0-9]{3,}|^$' to accept empty strings where tokens "|^$" allow empty strings.

Regards, Vladimirs

vpasedko avatar Oct 12 '20 23:10 vpasedko