This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const postObj = {}; | |
function parseTree(root) { | |
for (const child in root) { | |
const choice = values[child]; | |
if (!isEmpty(choice.value)) { | |
// push the value in post object | |
postObj[choice.name] = choice.value; | |
} | |
if (root[child]) { | |
// call parse tree with the child |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const decisionTree = { | |
DRINKS: { | |
ALCOHOLIC: { | |
PREFREENCES: { | |
WINE: { | |
DRINK_NAME: NULL, | |
}, | |
BEER: { | |
DRINK_NAME: NULL, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function basicField(Field, key) { | |
class BasicField extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
} | |
handleChange(value, error) { | |
// run validations | |
const { validations } = this.props.field; | |
const errors = [error].filter(v => v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"fieldKey": { | |
"name": "billingCycle", | |
"displayName": "Billing Cycle", | |
"validations": ["REQUIRED", "AMOUNT"] | |
} | |
} |