+ Start a Discussion

validation rules in Lightning modal

I'm using a wrapper to display the standard record edit screen in a modal. However, none of the validation rules are being handled. They are still being triggered somehow, because the force:recordSaveSuccess is not being sent when there is an error.

Ideally, I would simply get the same behavior within the modal that I get in the default screen (dependent fields highlighted in red with error messages). As it is, there is no indication of the errors anywhere.

This is how I call the edit screen from within the lightning modal
<force:recordEdit aura:id="edit" recordId="{!v.itemRecordId}"/>

I hope I've stated this clearly. I appreciate any help or suggestions.
Ajay K DubediAjay K Dubedi
Hi JohnB,
Please try this validation code:
    validateEmail : function(component, event, helper) {
        var isValidEmail = true; 
        var emailField = component.find("leadEMail");
        var emailFieldValue = emailField.get("v.value");
              emailField.set("v.errors", [{message: null}]);
              $A.util.removeClass(emailField, 'slds-has-error');
              isValidEmail = true;
             $A.util.addClass(emailField, 'slds-has-error');
             emailField.set("v.errors", [{message: "Please Enter a Valid Email Address"}]);
             isValidEmail = false;
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi