l
На основании конфига и его данных нужно построить новые гарды, используя данные из этого конфига и других ивентов
Size: a a a
l
c
YL
YL
YL
l
SM
const loginForm = createForm({
fields: {
email: {
init: "",
rules: [
{
name: "required_if",
source: $needToValidate,
validator: (value, form, needToValidate) => {
if (!needToValidate) return true
return Boolean(value)
}
},
],
},
},
})
let schema = object({
isBig: boolean(),
count: number()
.when('isBig', {
is: true, // alternatively: (val) => val == true
then: yup.number().min(5),
otherwise: yup.number().min(0),
})
.when('$other', (other, schema) => (other === 4 ? schema.max(6) : schema)),
});
await schema.validate(value, { context: { other: 4 } });
const loginForm = createForm({
fields: {
email: {
init: "",
rules: [
{
name: "required_if",
source: $needToValidate,
validator: (value, form, needToValidate) => yup.scheme().when(и вот тут юзать needToValidate) },
],
},
},
})
A
☬
АБ
MK
c
DS
1
DS
function createMessageStructure () {
const push = createEvent()
const delete = createEvent()
const $store = createStore([])
.on(push, (state, pushPayload) => [...state, ...pushPayload])
.on(remove, (state, deleteItem) =>
state.filter(item => item.id !== deleteItem.id)
)
return [$store, push, delete]
}
// Usage
const [$messageImages, pushImages, removeMessageImage] = createMessageStructure()
const [$messageDocuments , pushDocuments , removeMessageDocument] = createMessageStructure()1
1
DS
1