Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (field) {
// Prevent listener leak
field.destroy();
}
if (value.componentName) {
component = compiler.newComponent({
component: value.componentName
});
// Is the component a field?
if (component.isField) {
field = component;
} else {
// e.g. Text component is not a field
field = new ComponentField({ content: component });
}
// Auto validate so that the user can preview how the validation will work
const validate = () => {
field.clearErr();
field.validate();
};
field.on('value', validate);
field.on('touched', validate);
} else {
field = null;
}
}
if (field) {
// Set field values using form values. The corresponding values may not exist if the field was