Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require parsed values for other values #1

Open
RafaelVidaurre opened this issue Feb 19, 2015 · 1 comment
Open

Require parsed values for other values #1

RafaelVidaurre opened this issue Feb 19, 2015 · 1 comment

Comments

@RafaelVidaurre
Copy link

A problem that happens sometimes is that some values of our schema are not scraped but rather deducted from other values.

Its for this that we would need some sort of value dependency, where a certain value can require another value from the object being built.

Some challenges have to do with circular dependency which would have to be detected somehow I guess.

Also, dependencies would have to be returned in the order they are defined in the requires array.

var someSchema = {
  firstName: '#profile.name',
  lastName: '#profile.last',
  fullName: {
    requires: ['firstName', 'lastName'],
    $fn: function (values) {
      return values[0] + ' ' + values[1];
    }
  }
}
@RafaelVidaurre
Copy link
Author

Real life example:

  type: {
    $requires: ['description'],
    $fn: function (value) {
      if (value.indexOf('CUOTA ') > -1){
        return 'due';
      } else if (value.indexOf('CUOTAS ') > -1){
        return 'total_due';
      } else{
        return 'normal';
      }
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant