Created
January 25, 2020 19:21
-
-
Save cchrisv/39ee27b99c5369a671f4840c422d5e00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit: function(component, event, helper) { | |
helper.hlpCheckValidity(component, event); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
hlpCheckValidity: function(component, event) { | |
component.set("v.validate", function() { | |
var selectedValue = component.get("v.selectedValue"); | |
var required = component.get("v.required"); | |
var label = component.get("v.label"); | |
if (!required || (selectedValue && !$A.util.isEmpty(selectedValue))) { | |
return { isValid: true }; | |
} else { | |
return { | |
isValid: false, | |
errorMessage: "A selection is required for: " + label | |
}; | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment