Skip to main content

apply()

Call Signature​

function apply<V>(group, schema): void;

Defined in: packages/reformer/src/form/validation/operators.ts:237

Подключить схему подформы к группе модели — одной или нескольким.

Схема запускается в области группы: model в ней — под-модель, cross получает снапшот группы. Привязка — ручка model.$.<группа>, как у узла-подформы схемы и у apply поведения.

Type Parameters​

V​

V extends object | null | undefined

Parameters​

group​

GroupBinding<V> | GroupBinding<V>[]

schema​

ValidationDefinition<NonNullable<V>>

Returns​

void

Example​

const addressRules = defineValidation<Address>(({ model }) => {
validate(model.$.city, [required()]);
});

apply(model.$.registrationAddress, addressRules);
validateWhen(
() => !model.sameAsRegistration,
() => apply(model.$.residenceAddress, addressRules)
);

Call Signature​

function apply<T>(...schemas): void;

Defined in: packages/reformer/src/form/validation/operators.ts:250

Композиция схем над ТОЙ ЖЕ моделью области — так форма собирается из схем шагов.

Type Parameters​

T​

T

Parameters​

schemas​

...ValidationDefinition<T>[]

Returns​

void

Example​

const formRules = defineValidation<Form>(() => apply(loanRules, contactsRules));