
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@nexapp/nexapp-react-forms
Advanced tools
Form utilities in React
Exposes a hook taking an initialData
object. You can use it to receive the formData
of the object as well as an onChange
method. The onChange
method will adapt it's parameters according to the type of the initialData
.
For example you have an initialData
like this:
{
"details": {
"name": "value"
},
"inventory": {
"quantity": 15
}
}
When giving an object like this to the useFormData
hook, the onChange
method will be callable like this: onChange("details")("name")("newValue")
. Which will change the formData
from the hook with the updated value in the details.name field. For the moment this method can only go one level 2 level deep so any complex objects will have to be update entirely when calling this method.
We use this hook to simplify our forms. We can then structure our form to represent each section of the data structure. Then each section will receive the underlying section. We can then give them formData.details
as value and onChange("details")
as onChange method. Giving us maximum flexibility to add/remove/change fields of the data structure without impacting the props we give to each components.
This library exposes a FormValidator to validate data received from the useFormData
hook. It is possible to configure a FormValidator by extending the class, and passing the interface of your form data structure as template. You can then configure a set of rules for each property of the object. For exemple:
interface CreateAccountFormData {
name: string;
email: string;
password: string;
confirmedPassword: string;
}
class CreateAccountFormValidator
extends FormValidator<CreateAccountFormData> {
constructor(formData: CreateAccountFormData) {
super(formData);
this.rules = ({
name: [isEmpty],
email: [isEmpty, isEmail],
password: [isEmpty, isPassword],
confirmedPassword: [isEmpty, isSame(formData.password)],
});
}
}
A set of rules is given with the library but you can define your own rules by respecting the same signature. All you have to do after is to give your form data to your validator and call the validate
method. Which will update the validator's error property.
const submit = (): void => {
const validator = new CreateAccountFormValidator(account);
validator.validate();
if (validator.hasError()) {
setErrors(validator.errors);
}
};
FAQs
Form utilities in react
We found that @nexapp/nexapp-react-forms demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.