[SalesForce] Lightning:Input – Hide (Reset) Field Level Error message Enabled by using showHelpMessageIfInvalid()

Have few Lightning:Input and Lightning:Select components in My Component A.
All the fields are having Required attribute as 'true'.
Once fields are validated, Field level error (help) messages appear at the bottom of the field and will be there until input Field data is changed (is valid). I have used showHelpMessageIfInvalid() to enable this error message on field explicitly from controller.

I would like to Reset(Hide) the error messages on all these fields from Controller.
Is there any way to do this?
Looks like "errors" is not a valid attribute for Lightning:Input / Lightning:Select components. Below attempt failed.

component.find('FieldAuraID').set('v.errors', null);

Thanks

Best Answer

If you really wanted to hide error messages you could do something like this:

Component:

<div>
    <lightning:input label="First Name" aura:id="firstName" required="true"/>
    <lightning:button onclick="{!c.hideErrors}">Hide Errors</lightning:button>
</div>

Controller:

hideErrors : function(component, event, helper) {
    var el = component.find("firstName");
    $A.util.removeClass(el, "slds-has-error"); // remove red border
    $A.util.addClass(el, "hide-error-message"); // hide error message
}

Style:

.THIS .hide-error-message > .slds-form-element__help {

.THIS .hide-error-message > .slds-form-element > .slds-form-element__help {
    display: none;
}

But the internal DOM structure and class names of base components are subject to change so this isn't a totally robust solution.