Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

factorial-form

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factorial-form - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

coverage/clover.xml

10

__tests__/Field.spec.ts

@@ -222,2 +222,12 @@ import { Field } from '../src'

})
describe('reset', () => {
it('resets a field to its original value', () => {
const field = new Field('paco', 'string')
field.set('ferran')
expect(field.value).toBe('ferran')
field.reset()
expect(field.value).toBe('paco')
})
})
})

@@ -158,2 +158,13 @@ import { Form } from '../src'

describe('resetAll', () => {
it('resets form to its original values', () => {
form.setValues({ name: 'resetMe', age: 20 })
expect(form.get('name').value).toBe('resetMe')
expect(form.get('age').value).toBe("20")
form.resetAll()
expect(form.get('name').value).toBe('paco')
expect(form.get('age').value).toBe("0")
})
})
describe('setErrors', () => {

@@ -160,0 +171,0 @@ it('populates the fields with errors', () => {

4

CHANGELOG.md
# Changelog
## `2.1.0`
- Add `reset` and `resetAll` methods
## `2.0.0`

@@ -4,0 +8,0 @@

10

lib/index.d.ts

@@ -22,2 +22,3 @@ declare type Type = 'date' | 'timestamp' | 'number' | 'string' | 'file' | 'boolean' | 'cents' | 'any';

clean(): void;
reset(): void;
setErrors(errors: Array<string> | null): void;

@@ -59,7 +60,12 @@ }

/**
* Cleans all the forms by reseting their original
* values
* Cleans all the forms by changing their original
* values to correspond to their current values
*/
cleanAll(): void;
/**
* Reset all the forms to their original
* values thereby discarding all changes made
*/
resetAll(): void;
/**
* Resets all the error fields

@@ -66,0 +72,0 @@ */

@@ -199,2 +199,5 @@ 'use strict';

};
Field.prototype.reset = function () {
this.value = this.originalValue;
};
Field.prototype.setErrors = function (errors) {

@@ -241,4 +244,4 @@ this.errors = errors;

/**
* Cleans all the forms by reseting their original
* values
* Cleans all the forms by changing their original
* values to correspond to their current values
*/

@@ -251,2 +254,11 @@ Form.prototype.cleanAll = function () {

/**
* Reset all the forms to their original
* values thereby discarding all changes made
*/
Form.prototype.resetAll = function () {
forEach__default['default'](this.fields, function (field) {
return field.reset();
});
};
/**
* Resets all the error fields

@@ -253,0 +265,0 @@ */

{
"name": "factorial-form",
"version": "2.0.0",
"version": "2.1.0",
"description": "Factorial form library",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc