Field level validation - get name of the currently validated field - redux-form

I would like to get name of currently validated field (per-field sync validation - the one passed as validate prop to Field). Is it possible with redux form 7.0.3?

Related

Apply Sitecore validation rule to a field type?

I have created a validation rule in Core DB, and I have created a custom Sitecore field called 'Single Select Treelist'. I want to apply this validation rule to all 'Single Select Treelist' fields in all templates in my Sitecore instance.
I know we can individually apply the validation rule to each template field of type 'Single Select Treelist'. Is there a way to achieve this automatically for all 'Single Select Treelist' fields without any custom coding?
I see the list of field type validation rules available in Master:
How are these connected to the respective field types in Core?
Please advise.
If you edit the field type item there is a validation section that contains fields to set validation rules for the Quick Action Bar, the Validate Button, the Validator Bar and finally Workflow.
Once you set the validation rules, depending on which field you set, Sitecore will display the validation messages in different ways. See this blog post for examples: http://sitecoreworld.blogspot.com/2014/12/sitecore-validation-examples.html
The link between the Field Type Validation Rule and the actual Field Type seems to be based simply on the name of the Field Type.
Just add a new item with the template "Field Type Validation Rules" in the Validation Rules/Field Types folder that you show in your picture. Give it the exact same name as the field type you want it to validate. Select the rules you need inside the Validation Rules section of that new object.
For example, I just needed to add some validation to the Single-Line Text type, as you can see in the image. We struggled with it for a little while because we missed the dash.
Image - Sitecore Tree with new Field Type Validation

How to validate not blank values in Access Data Validation

I'm just wondering if there is a way in Access Data Validation to run if and only if the fields they are validating are not blank? In other words, do not run data validation if the corresponding fields are blank?
Must I insert an if expression before the data validation rule to do so?

Throwing a message when Updating/Validating Part contents/data

Crosspost: https://orchard.codeplex.com/discussions/455498
When updating a Part, in the DriverResult Editor, how can we manually throw a warning message when implementing custom validation?
I want to add a custom validation for some date fields, where values are dependent on some other field in the Content Item itself (dates in the part need to be between a specific date in the content item's field).
Which leads me to another question, can we set validation in model properties between one another? Like if there are two properties StartDate and EndDate, is it doable in the model to declare that end date must be after start date?
You can add model validation errors using the "updater" parameter being passed in:
updater.AddModelError("StartDate", T("Please enter a date in the future"));

JSR 303 - Validate a field if it is not null

I have a form which is filled in, and some of the fields are options. I want to apply validations on the information that was filled in but the optional fields should be validated only if there was something filled in, so if theses are not null. Did any of you do something similar?
Or do you have any suggestion?
Bean Validation constraints usually accept null as valid value (with the exception of #NotNull of course). Depending on your UI framework you might retrieve empty strings instead of null for fields without user input. If you're are working with JSF 2, you can set the context parameter javax.faces.VALIDATE_EMPTY_FIELDS to false to avoid a validation of empty fields.

Custom Data Annotation Attribute using Metadata

My requirement is to create a custom data annotation attribute for my project. The requirement is to validate the min/ max length of a specific product from the database, which will be retrieved from the database using the ProductID. I have a dynamic page for each product where there are two fields called max length & min length. User inputs the values in these two fields which needs to be validated from the database. Product table contains all the products & one will be selected by passing a productId.
Please suggest some pointers to implement the above.
Thanks in advance.
This validation you can do only in the server side and not in client, so I see two options.
Remote Validation - You can use remote validation when you want to perform the validation and show the error message through ajax.
IValidatableObject - By implementing this interface in the class you can do both the validations at the same time and return all the validation error messages as a collection. By this way the validation will happen after the form is normally submitted.

Resources