Skip to content

Instantly share code, notes, and snippets.

@riccoski
Created March 23, 2017 11:00
Show Gist options
  • Save riccoski/5ca97a7412b5be71869f55de4f0098c6 to your computer and use it in GitHub Desktop.
Save riccoski/5ca97a7412b5be71869f55de4f0098c6 to your computer and use it in GitHub Desktop.
import { computed, observable } from "mobx"
export default class VATNumber {
@observable valid
@observable format_valid
@observable query
@observable country_code
@observable vat_number
@observable company_name
@observable company_address
store = null
constructor(store, data) {
if ( data != null ) {
Object.assign(this, { ...data });
}
this.store = store
}
updateFromServer(data) {
if ( data != null ) {
Object.assign(this, { ...data });
}
console.log("is valid", this.valid);
}
@computed get asJSON() {
return {
country_code: this.country_code,
vat_number: this.query
}
}
@computed get isInvalid() {
console.log("this.valid", this.valid);
return (this.valid === false)
}
@computed get isValid() {
console.log("this.valid", this.valid);
return (this.valid === true)
}
validate() {
this.store.validateVATNum(this.asJSON)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment