Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
final-form-app-form
Advanced tools
npm install final-form-app-form
import { Field } from "react-final-form";
import { useForm } from "final-form-app-form";
interface IFormValues {
firstName: string;
lastName: string;
}
interface IPageProps {
initialValues: IFormValues;
}
interface IPageCallProps {
submit;
}
type Props = IPageProps & IPageCallProps;
const Page = (props: Props) => {
const {
initialValues,
submit,
} = props;
const [ Form, submitOnClick ] = useForm<IFormValues>(submit);
return (
<div>
<Form initialValues={initialValues}>
<div>
<label>First Name</label>
<Field
name="firstName"
component="input"
type="text"
/>
</div>
<div>
<label>Last Name</label>
<Field
name="lastName"
component="input"
type="text"
/>
</div>
</Form>
{/* some other components*/}
<button onClick={submitOnClick}>
submit form remotely
</button>
</div>
);
};
import { Field } from "react-final-form";
import { useForm } from "final-form-app-form";
import { ModelState, IValidator } from "model-state-validation";
interface IFormValues {
firstName: string;
lastName: string;
}
class FormValuesValidator implements IValidator<IFormValues> {
validate(model: IFormValues): ModelState {
const modelState = new ModelState();
if (!model.firstName) {
modelState.addError("firstName", "required field");
}
if (!model.lastName) {
modelState.addError("firstName", "required field");
}
return modelState;
}
}
interface IPageProps {
initialValues: IFormValues;
}
interface IPageCallProps {
submit;
}
type Props = IPageProps & IPageCallProps;
const Page = (props: Props) => {
const {
initialValues,
submit,
} = props;
const [ Form, submitOnClick ] = useForm<IFormValues>(submit, new FormValuesValidator());
return (
<div>
<Form initialValues={initialValues}>
<div>
<label>First Name</label>
<Field name="firstName" >
{({ input, meta }) => (
<>
<input {...input} type="text" />
{meta.error && meta.touched && <span>{meta.error}</span>}
</>
)}
</Field>
</div>
<div>
<label>Last Name</label>
<Field name="lastName" >
{({ input, meta }) => (
<>
<input {...input} type="text" />
{meta.error && meta.touched && <span>{meta.error}</span>}
</>
)}
</Field>
</div>
</Form>
{/* some other components*/}
<button onClick={submitOnClick}>
submit form remotely
</button>
</div>
);
};
import { FormState } from "final-form";
import { Field } from "react-final-form";
import { useForm } from "final-form-app-form";
interface IFormValues {
firstName: string;
lastName: string;
}
interface IPageProps {
initialValues: IFormValues;
}
interface IPageCallProps {
submit;
}
type Props = IPageProps & IPageCallProps;
const Page = (props: Props) => {
const {
initialValues,
submit,
} = props;
const [ Form, submitOnClick ] = useForm<IFormValues>(submit);
return (
<div>
<Form initialValues={initialValues} subscribe={{ pristine: true }}>
{(state: FormState) => (
<>
<div>
<label>First Name</label>
<Field
name="firstName"
component="input"
type="text"
/>
</div>
<div>
<label>Last Name</label>
<Field
name="lastName"
component="input"
type="text"
/>
</div>
<p>
{state.pristine ? "form is pristine" : "form is dirty"}
</p>
</>
)}
</Form>
{/* some other components*/}
<button onClick={submitOnClick}>
submit form remotely
</button>
</div>
);
};
import { useState } from "react";
import { useForm } from "final-form-app-form";
import { ModelState, IValidator } from "model-state-validation";
interface IFormValues {
firstName: string;
lastName: string;
}
class FormValuesValidator implements IValidator<IFormValues> {
validate(model: IFormValues): ModelState {
// validation logic
// ...
}
}
const Page = (props) => {
const {
initialValues,
submit,
} = props;
const [ validationMessage, setValidationMessage ] = useState("");
const [ Form, submitOnClick ] = useForm<IFormValues>(
submit,
new FormValuesValidator(),
{
setCommonErrorMessage: setValidationMessage,
validateOnFieldsChange: true,
resetValidationErrorOnActiveField: true,
validateOnFieldsBlur: true,
// validateSpecifiedFieldsOnBlur: [ "firstName" ],
}
);
return (
<div>
// render form etc
// ...
<p style={{ color: "red" }}>
{validationMessage}
</p>
</div>
);
};
FAQs
utils for final form using
The npm package final-form-app-form receives a total of 0 weekly downloads. As such, final-form-app-form popularity was classified as not popular.
We found that final-form-app-form demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.