
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
aca-form-generator
Advanced tools
You can find a succint storybook detailing main components props and events : https://aca-form-generator.netlify.com/storybook/
You can find a succint storybook detailing main components props and events :
https://aca-form-generator.netlify.com/storybook/
FormGenerator is a component used to display a form, without styling.
It takes a JSON object describing the form and data. It handles user inputs. It returns validation errors.
It doesn't handle sending to the form to any backend. It doesn't handle step navigation.
npm install aca-form-generator
import { FormGenerator } from 'aca-form-generator'
<script>
export default {
components: {
FormGenerator,
},
data() {
return {
errors: {},
visibleErrors: {},
schema: {},
model: {},
}
}
}
</script>
<template>
<FormGenerator
:schema="schema"
:model="model"
:errors="errors"
:visibleErrors="visibleErrors"
@fieldChange="({ field, value }) => this.model = Object.assign({}, this.model, { [field.model]: value })"
@errorsChange="({ errors }) => (this.errors = errors)"
>
</FormGenerator>
</template>
schema : required
Literal object describing the form.
{
fields: [
{
type: 'input',
model: 'username'
},
// ...
]
}
You can find more example of common fields in this file :
https://github.com/Acadomia/aca-form-generator/blob/master/src/stepsSkeletonExample.js
model
Literal object representing the data displayed in the different fields :
{
username: 'my-username'
}
errors
Literal object representing the errors :
{
username: ['this field is required.']
}
visibleErrors
Literal object representing the errors displayed :
{
username: true
}
fieldChange
Emitted when the user is typing in an input for example.
Parent component is responsible for updating the model prop accordingly :
<FormGenerator
:model="this.model"
@fieldChange="({ field, value }) => this.model = Object.assign({}, this.model, { [field.model]: value })"
<!-- ... -->
errorsChange
Emitted when a field validations messages change.
Parent component can listen to the event to disabled "submit" button for example :
<FormGenerator
@errorsChange="({ errors }) => this.errors = errors"
<!-- ... -->
<button
:disabled="errors.length"
<!-- ... -->
fieldFocus
Emitted when a field gains focus.
<FormGenerator
@fieldFocus="({ field }) => ..."
<!-- ... -->
fieldBlur
Emitted when a field loses focus.
Useful to manipulate visibleErrors.
<FormGenerator
@fieldBlur="({ field }) => ..."
<!-- ... -->
For the moment FormGenerator can only render these fields:
checklistselectcheckboxradioinputnumeric-inputtextareazipcodeuploadhtmlNew fields can easily be added to FormGenerator.vue
Every field must have at least a field props, describing the field,
And a value prop describing its value.
It must emit an event valueChange when the value changes.
Each field is wrapped in a slot.
So you can easily create a custom field, or change an existing field behaviour.
<FormGenerator
:schema="{ field: [ { type: 'myCustomField', ... }, ... ] }"
...
>
<template #myCustomField="{ field, value }">
<!-- create your field here using {{ field }} and {{ value }} variables-->
</template>
</FormGenerator>
Validation is done when the model changes by calling the validators functions defined in each schema.fields[].validators
Validators are defined in this file :
https://github.com/Acadomia/aca-form-generator/blob/master/src/fieldValidators.js
Each validator is a function retuning undefined when the field value is valid.
Or an array of error messages when something is invalid.
The validator function takes 3 arguments:
field the field whe want to validatemodel all the values for the given formmessages a facultative object with the translated error messages.import { fieldValidators } from 'aca-form-generator'
A minimal validator could look like this :
checked(field, model) {
if (!model[field.model]) {
return ['This checkbox must be checked']
}
},
A more complete example would be:
checked(field, model, messages) {
if (!model[field.model]) {
return [messages.mustBeChecked]
}
},
You can transate or customize the error messages using the function withMessages.
fieldValidators.checked.withMessages({
mustBeChecked: 'Ce champ doit être coché.'
})
Using the scopped slot errors you can customize validation errors.
<FormGenerator
...
>
<template #errors="{ field, errors }">
<!-- Display errors here, the way you want. -->
</template>
</FormGenerator>
Just like validators, to keep the code reusable, step logic is not coupled to the component FormGenerator
The mixin stepMixin.js is here to help you handle multi step forms.
You can find an example of how to use all these elements together to make a multistep form generated with a JSON comming from an API here :
https://github.com/Acadomia/aca-form-generator/blob/master/src/screens/ExampleScreen.vue
You can also find the code of the mixin here :
https://github.com/Acadomia/aca-form-generator/blob/master/src/stepsMixin.js
import { stepsMixin } from 'aca-form-generator'
FAQs
You can find a succint storybook detailing main components props and events : https://aca-form-generator.netlify.com/storybook/
The npm package aca-form-generator receives a total of 70 weekly downloads. As such, aca-form-generator popularity was classified as not popular.
We found that aca-form-generator demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.