Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@heridux/form
Advanced tools
Extends Heridux
Form store constructor
STATE_PROPERTY
String? string name for this store (if you plan to use it with redux)import HeriduxForm from "@heridux/form"
import Rules from "@heridux/rules"
const store = new HeriduxForm("myForm")
store.defineForm({
name : Rules.string.isRequired,
age : Rules.number,
address : {
street : Rules.string,
city : Rules.string,
zipCode : Rules.number
}
})
// register store in redux store (see @heridux/core for more details)
store.register()
store.initFormValues({
name : "Roger",
age : 56
})
store.setFieldValue(["address", "city"], "Paris")
store.getFieldValue("age") // 56
Returns undefined
Defines structure of the form
fields
Object object describing the form (field name in key, Rules object in value)import HeriduxForm from "@heridux/form"
import Rules from "@heridux/rules"
const store = new HeriduxForm("myForm")
store.defineForm({
name : Rules.string.isRequired,
age : Rules.number,
address : {
street : Rules.string,
city : Rules.string,
zipCode : Rules.number
}
})
// register store in redux store (see @heridux/core for more details)
store.register()
Returns undefined
Initialization of the form. Undeclared fields will be ignored.
values
Object initialization valuesimport HeriduxForm from "@heridux/form"
import Rules from "@heridux/rules"
const store = new HeriduxForm("myForm")
store.defineForm({
name : Rules.string.isRequired,
age : Rules.number
})
store.register()
store.initFormValues({
name : "Roger",
age : 56,
address : "Paris"
})
// initFormValues won't consider form has been touched
store.get("touched") // false
// unknown keys are ignored
store.getFieldValue("address") // null
Returns undefined
Initialization of part of the form. Undeclared fields will be ignored.
import HeriduxForm from "@heridux/form"
import Rules from "@heridux/rules"
const store = new HeriduxForm("myForm")
store.defineForm({
name : Rules.string.isRequired,
age : Rules.number,
address : {
street : Rules.string,
city : Rules.string,
zipCode : Rules.number
}
})
store.register()
store.initFormValuesIn(["address"], {
street : "Victor Hugo",
city : "Toulouse",
zipCode : 31000
})
// initFormValuesIn won't consider form has been touched
store.get("touched") // false
store.getFormValues()
// {
// name : null,
// age : null,
// address : {
// street : "Victor Hugo",
// city : "Toulouse",
// zipCode : 31000
// }
//}
Returns undefined
Check validity of the form
_formValues
Object? values to check if they are not those of the store (optional, default null
)Returns Boolean true if all fields are valid, false otherwise
Cancel modifications (return to the initial values defined by the initFormValues method)
Returns undefined
Cancel modifications to part of form (return to the initial values defined by the initFormValues method)
path
Array entry pointReturns undefined
Réinitialisation des valeurs du formulaires (toutes fixées à null)
Returns undefined
Réinitialisation d'une partie des valeurs du formulaires (toutes fixées à null)
path
Array point d'entréeReturns undefined
Ajout dynamique de champs dans le formulaire (postérieur à la méthode defineForm)
path
(Array | String) chemin où insérer les nouveaux champsfields
Object objet dont les clés sont les noms des champs et les valeurs les règles
de validationReturns undefined
Suppression dynamique de champs de formulaire
Returns undefined
Attribution d'une valeur à un champ
Returns undefined
Initialisation d'un champ
Returns undefined
Annulation des modifications d'un champ (retour à la valeur initiale)
Returns undefined
Définition d'un message d'avetissement
path
(Array | String) chemin du champmessage
String contenu du messageproperties
Object propriétés supplémentaires liées à l'erreurReturns undefined
Définition d'un message d'erreur
path
(Array | String) chemin du champmessage
String contenu du messageproperties
Object propriétés supplémentaires liées à l'erreurReturns undefined
Définition d'une erreur globale sur le formulaire
error
String contenu de l'erreurReturns undefined
Teste si le formulaire a été modifié
state
Immutable.Map optionnel état du store si on l'a sous la mainReturns Boolean true si le formulaire a été modifié, false sinon
Teste si le formulaire contient des erreurs. Attention, il ne lance pas les validations mais se contente de vérifier si des erreurs ont été levées.
state
Immutable.Map optionnel état du store si on l'a sous la mainReturns Boolean true si le formulaire contient des erreurs, false sinon
Récupère l'ensemble des erreurs du formulaire sous forme de tableau
state
Immutable.Map optionnel état du store si on l'a sous la mainReturns Array tableau des erreurs
Attribue les valeurs au formulaire. Attention, les validations ne sont pas lancées car certaines peuvent être interdépendantes (si besoin exécuter la méthode checkForm ensuite)
values
Object objet contenant les valeursReturns undefined
Attribue des valeurs au formulaire. Attention, les validations ne sont pas lancées car certaines peuvent être interdépendantes (si besoin exécuter la méthode checkForm ensuite)
path
Array optionnel, point d'entrée si on ne veut affecter qu'une partie du formulairevalues
Object objet contenant les valeursReturns undefined
Retrieves form values
_state
Immutable.Map? state of the store if availableReturns Object object describing values
Retrieves values of a form part
Returns Object object describing values
Retrieves field value
Returns any field value
Retrieves the warning message of a field
Returns String warning message
Retrieves the error message of a field
Returns String error message
Tests if a field has been modified
Returns Boolean true if the field has been modified
Completely reset the form structure
Returns undefined
Set current values as initial values. Form will be considered unmodified. Warning : field rules won't be check (use checkForm if needed)
import HeriduxForm from "@heridux/form"
import Rules from "@heridux/rules"
const store = new HeriduxForm("myForm")
store.defineForm({
name : Rules.string.isRequired,
age : Rules.number
})
store.register()
store.setFieldValue("name", "Roger")
store.setFieldValue("age", "56")
store.get("touched") // true
store.validateForm()
store.get("touched") // false
store.cancelFormValues() // no effect since values are now considered as initial values
Returns undefined
Checks if a field is registered at path passed as argument
path
Array key pathReturns Bool true if a field is registered
FAQs
Manage your forms easily with heridux-form
The npm package @heridux/form receives a total of 1 weekly downloads. As such, @heridux/form popularity was classified as not popular.
We found that @heridux/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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.