Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
effector-final-form
Advanced tools
☄️ Effector bindings for Final Form 🏁
Forms values and validation rules are part of the business logic. This means that you need to be able to work with them without being bound to the UI-framework.
The goal of this project is to combine Final Form and Effector to achieve the goal described above.
yarn add effector-final-form
# or
npm add effector-final-form
# or
pnpm add effector-final-form
Just import from the root module:
import { createForm } from 'effector-final-form';
import { vi } from 'vitest';
import waitForExpect from 'wait-for-expect';
// import { createForm } from 'effector-final-form';
import { createForm } from '../../index';
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
describe('example', () => {
test('', async () => {
const { $formState, $fields, api } = createForm({
onSubmit: async (f) => {
await sleep(1000);
return f.firstName === 'Incorrect' ? { firstName: 'Submit Error' } : undefined;
},
validate: (f) => (f.firstName === '' ? { firstName: 'Can not be empty' } : undefined),
initialValues: { firstName: '' },
subscribeOn: ['values', 'errors', 'submitting', 'submitSucceeded', 'submitFailed', 'submitErrors'],
});
await api.registerField({
name: 'firstName',
subscribeOn: ['value', 'error', 'initial'],
});
api.changeFx({ name: 'firstName', value: '' });
await waitForExpect(() => {
expect($fields.getState().firstName.error).toBe('Can not be empty');
});
expect($fields.getState().firstName.initial).toBe('');
expect($fields.getState().firstName.value).toBe('');
expect($formState.getState().errors).toStrictEqual({ firstName: 'Can not be empty' });
expect($formState.getState().values).toStrictEqual({ firstName: '' });
expect($formState.getState().submitting).toBe(false);
expect($formState.getState().submitSucceeded).toBe(false);
expect($formState.getState().submitFailed).toBe(false);
expect($formState.getState().submitErrors).toBe(null);
{
await api.changeFx({ name: 'firstName', value: 'Incorrect' });
await waitForExpect(() => {
expect($fields.getState().firstName.error).toBe(undefined);
expect($fields.getState().firstName.value).toBe('Incorrect');
expect($formState.getState().errors).toStrictEqual({});
});
}
{
const submitPromise = api.submitFx();
expect($formState.getState().submitting).toBe(true);
vi.useFakeTimers();
vi.runOnlyPendingTimers();
await submitPromise;
vi.useRealTimers();
expect($formState.getState().submitting).toBe(false);
expect($formState.getState().submitSucceeded).toBe(false);
expect($formState.getState().submitFailed).toBe(true);
expect($formState.getState().submitErrors).toStrictEqual({ firstName: 'Submit Error' });
}
{
await api.changeFx({ name: 'firstName', value: 'John' });
expect($fields.getState().firstName.error).toBe(undefined);
expect($fields.getState().firstName.value).toBe('John');
expect($formState.getState().errors).toStrictEqual({});
const submitPromise = api.submitFx();
await waitForExpect(() => {
expect($formState.getState().submitting).toBe(true);
});
vi.useFakeTimers();
vi.runOnlyPendingTimers();
await submitPromise;
vi.useRealTimers();
await waitForExpect(() => {
expect($formState.getState().submitting).toBe(false);
});
expect($formState.getState().submitSucceeded).toBe(true);
expect($formState.getState().submitFailed).toBe(false);
expect($formState.getState().submitErrors).toBe(null);
}
});
});
FAQs
☄️ Effector bindings for Final Form
The npm package effector-final-form receives a total of 6 weekly downloads. As such, effector-final-form popularity was classified as not popular.
We found that effector-final-form demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.