jquery validate custom rule with ajax field and more than 1 message - jquery-validate

I have to make a custom validation for a fiel what be must validate by api.
The server response is always a array [], that can be empty, 1 result, n result.
My valid case is when is exaclty 1, the other 2 must be separeted in two diferent error messages.
The problem particulary is, the default remote option doesn´t work for my custom rule, and the async validation always fail.
Considere this code as example :
http://jsfiddle.net/84fefw4z/2/
How can add a remote rule validation with: jQuery.validator.addMethod(...); ?
Is possible add a rule with 2 error messages?

Related

Run all the validations for a field in react-hook-form

I am using react-hook-form in my project. I have multiple validators for a same field in my form. Example: firstName field has two validators, 1. minLength, 2. a pattern validator.
{...register("firstName", {
minLength: 5,
pattern: /^[A-Za-z]+$/i
})}
There might be possibility that both validation may fail at same time, and I need to show both errors one below another. But formState.errors object only have one error. So for above example if the value is 123 then it should show both error messages one below another, but it shows minLength error message only.
Here is the code sample - https://codesandbox.io/s/react-hook-form-apply-validation-forked-377q8f?file=/src/index.js:587-692

IBM Integration Toolkit Issue for Validation

I am working on IBM Integration toolkit. I wanted to understand the exact validation feature of a particular input node via an example. Can anyone help?
Validation on inputs node you can see them in validation tab, you can choose how to validate (content, conent and value or none if you like to implement your own vaildation and what to do if this validate is failure (Exception , Exception List , user trace, log local error),
validation done automatically depends on the message parser : [BLOB, XMLNSC, XMLNS, SOAP, MRM, ..etc ], and message structurewhich is defined in your message set.
for example :
If you create a message set with message definition file and this message definition has got and element and this element is required and integer, and you set this message set to your input node, validation feature runs automatically if you put for example string value or you left it empty validation exception occurs.

Is there a way to make angular run all the validations of an input instead of stoping when the first validation fails?

I'm having problems trying to make angular run all the validations of an input at once.
Here is a jsfiddle example of my problem http://jsfiddle.net/carpasse/GDDE2/
if you type 1 character on the email input you get this "The minimum lenght is 3." error message
and is not until you type 2 more characters than you get the other error message "This is not a valid email."
Does anybody know how to make angular show both error messages at the same time??
Thanks a lot in advance
You problem is not that all the validators are not being run - they are!
Remember that the way these validations work is by passing the view values through a pipeline of transformation functions, which can also specify the validity of the value.
The problem is that the min length validator passes undefined down the pipeline if it is not valid and that the email validator says that undefined is a valid email address!
Try creating your own validation directive that says that undefined is not a valid email address and you will find both errors are showing: http://jsfiddle.net/eKfj3/

Organize validation messages in Struts2 validation(XML)

I am trying to do validations in struts 2 for my current project. I have to group my validation messages. For Eg: If there are 3 fields that are empty and there are 3 other fields whose format is not right, I need to get a msg like
"The following fields are required: field1, field2, field3
The format of the following fields are invalid: field4, field5, field6"
I tried providing a param to fieldError.
Eg:
< s : fielderror >
< s : param value="%{requiredstring}"/>
< / s : fielderror>
According to me this is like specifying "show all errors whose validator type is requiredstring". Please correct me if I am wrong.
But this will display the message "The following fields are required" each time for every field that is empty. I want it displayed only once.
Is there a way to do this cleanly in stuts2 using validation through xml? I donot want to do all the validations in a validate method.
Thanks
You are wrong; I have no idea why you thought that'd work, the docs don't imply that's possible.
Field errors are just that--errors for a specific field. If you need to group errors by arbitrary criteria, like the validation type, you'll need to implement that yourself.
There are a number of ways to do this, including writing a custom validation interceptor, providing validators that group errors in a different way, or simply gathering the appropriate messages in an action or validation method.
You could gather errors based on the message content, but IMO that would be brittle. If this is a cross-application issue, you're better off doing it a different way.
All that said, by presenting error messages in an order not necessarily reflective of the form, you're pushing more cognitive overhead onto the user: I don't want to see groups of messages telling me which fields share the same error, I want to see what's wrong with each field, in the same order the fields are presented on the form, preferably near the form field itself.

Struts2 parameter refilling on validation error

Suppose I have struts2 select tag in a form, when the form is submitted, according to the validation xml there's an error so input is returned.
Now my question is when input is returned the select box becomes empty. How to prevent it from becoming empty since because in validation error the execution never reaches the action's method (where we can possibly fill the select again).
One possible solution could be to validate the form within the action's method but I want to check the validation through XML only.

Resources