Iam trying to validate the field here. but iam getting below error

   "Cannot read property 'set' of undefined"

      <div class="slds-grid slds-gutters">
        <div class="slds-col">
        <span>   <!-- Description -->
            <div class="slds-form-element">
             <!--   <label class="slds-form-element__label" for="description">Description </label> -->
                <div style="width:200px;">
                    <ui:inputText class="description" aura:id="description" label="Description" value="{!v.myDescription}" required="true"/>
            </div> </span> 


  Savemethod:function(component, event, helper) {
    var description=component.find("description").get("v.value");
    if(description==null || description=='undefined' ){
        description.set("v.errors", [{message:"description cannot be blank"}]);

    else {
        description.set("v.errors", null);

1 Answer 1


You read the text string from the object. You need to set the value in the attribute:

component.find("description").set("v.errors", [{message:"description cannot be blank"}]);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .