Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const step = () =>
fields({
value: {},
instanceOf: flow(
withFields({
started: boolean({ value: false }),
startedOn: date(),
completed: boolean({ value: false }),
completedOn: date()
}),
withProps({
markAsStarted() {
this.started = true;
this.startedOn = new Date();
},
markAsCompleted() {
this.completed = true;
this.completedOn = new Date();
}
})
)()
});
list: true,
value: [],
instanceOf: FormFieldsModel
})
),
layout: onSet(value => (instance.locked ? instance.layout : value))(
object({ value: [] })
),
stats: skipOnPopulate()(fields({ instanceOf: FormStatsModel, value: {} })),
settings: onSet(value => (instance.locked ? instance.settings : value))(
fields({ instanceOf: FormSettingsModel, value: {} })
),
triggers: onSet(value => (instance.locked ? instance.triggers : value))(object()),
version: number(),
parent: string(),
publishedOn: date(),
published: onSet(value => {
if (value) {
instance.publishedOn = new Date();
if (!instance.locked) {
instance.locked = true;
}
}
return value;
})(boolean()),
locked: skipOnPopulate()(boolean({ value: false }))
})),
withHooks({
ip: string({ validation: validation.create("required") }),
locale: string({ validation: validation.create("required") }),
submittedOn: skipOnPopulate()(
date({ validation: validation.create("required") })
)
})()
}),
logs: fields({
list: true,
value: [],
instanceOf: withFields({
type: string({
validation: validation.create("required,in:error:warning:info:success"),
message: string(),
data: object(),
createdOn: date({ value: new Date() })
})
})()
})
})),
withHooks({
const step = () =>
fields({
value: {},
instanceOf: flow(
withFields({
started: boolean({ value: false }),
startedOn: date(),
completed: boolean({ value: false }),
completedOn: date()
}),
withProps({
markAsStarted() {
this.started = true;
this.startedOn = new Date();
},
markAsCompleted() {
this.completed = true;
this.completedOn = new Date();
}
})
)()
});