Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
I wish to understand this validation example in lightning

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_example.htm

In this example I want to understand "validateContactForm" method specially below part

What is this "reduce" and "showHelpMessageIfInvalid" do, any other reference help to understand it?

// Show error messages if required fields are blank

var allValid = component.find('contactField').reduce(function (validFields, inputCmp) {

inputCmp.showHelpMessageIfInvalid();

return validFields && inputCmp.get('v.validity').valid;

}, true);

 
2 answers
Loading
0/9000