2

Basically, I have very less edge cases where I need to change the value of props on init like so,

props : {
    columnName : String,
    setValue: {

        validator: function (value) {
            //enum edge cases
            let _value = value;
            if(value === 'YES' || value === 'ACTIVE'){
                value = 0;
            }
            else if(value === 'NO' || value === 'VOID'){
                value = 1;
            }
            console.log(_value);
            return _value;
        }
    }
},

Is this possible, I did try this but it is still sending the actual values instead of 0/1.

0

1 Answer 1

1

You could try to return 'value' rather than '_value'. However, I believe this is a job for a computed property, rather than trying to manipulate the prop directly.

computed:{
  computedSetValue(){
    if(this.setValue === 'YES' || this.setValue === 'ACTIVE'){
      return 0
    }
    else if(this.setValue=== 'NO' || this.setValue=== 'VOID'){
      return 1
    } 
    return 0      
  }
}

Then, you may use this.computedSetValue as you do this.setValue

Sign up to request clarification or add additional context in comments.

1 Comment

Great. Thanks for the quick help. I never knew this could be a possible way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.