Skip to content

Instantly share code, notes, and snippets.

@cchrisv
Created January 25, 2020 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cchrisv/39ee27b99c5369a671f4840c422d5e00 to your computer and use it in GitHub Desktop.
Save cchrisv/39ee27b99c5369a671f4840c422d5e00 to your computer and use it in GitHub Desktop.
({
doInit: function(component, event, helper) {
helper.hlpCheckValidity(component, event);
}
});
({
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