factorial-form
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -249,2 +249,25 @@ import { Field } from '../src' | ||
}) | ||
describe('hasValue', () => { | ||
it('returns true when value is set', () => { | ||
const field = new Field('paco', 'string') | ||
expect(field.hasValue).toBeTruthy() | ||
}) | ||
it('returns false when value is null', () => { | ||
const field = new Field(null, 'string') | ||
expect(field.hasValue).toBeFalsy() | ||
}) | ||
it('returns true when Field is boolean and value is false', () => { | ||
const field = new Field(false, 'boolean') | ||
expect(field.hasValue).toBeTruthy() | ||
}) | ||
it('returns false when Field is string and value is false', () => { | ||
const field = new Field(false, 'string') | ||
expect(field.hasValue).toBeFalsy() | ||
}) | ||
}) | ||
}) |
@@ -19,2 +19,3 @@ declare type Type = 'date' | 'timestamp' | 'number' | 'string' | 'file' | 'boolean' | 'cents' | 'any'; | ||
get isDirty(): boolean; | ||
get hasValue(): boolean; | ||
mapAndSet(value: any): void; | ||
@@ -21,0 +22,0 @@ set(value: any): void; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
var isObject = require('lodash/isObject'); | ||
var every = require('lodash/every'); | ||
var forEach = require('lodash/forEach'); | ||
@@ -27,2 +28,3 @@ var some = require('lodash/some'); | ||
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject); | ||
var every__default = /*#__PURE__*/_interopDefaultLegacy(every); | ||
var forEach__default = /*#__PURE__*/_interopDefaultLegacy(forEach); | ||
@@ -194,2 +196,16 @@ var some__default = /*#__PURE__*/_interopDefaultLegacy(some); | ||
}); | ||
Object.defineProperty(Field.prototype, "hasValue", { | ||
get: function () { | ||
switch (this.type) { | ||
case 'number': | ||
case 'cents': | ||
case 'boolean': | ||
return this.value !== '' && !isNull__default['default'](this.value); | ||
default: | ||
return !!this.value; | ||
} | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Field.prototype.mapAndSet = function (value) { | ||
@@ -301,12 +317,3 @@ this.value = this._mapIn(value); | ||
get: function () { | ||
return !some__default['default'](this.fields, function (field) { | ||
switch (field.type) { | ||
case 'number': | ||
case 'cents': | ||
case 'boolean': | ||
return field.value === '' || isNull__default['default'](field.value); | ||
default: | ||
return !field.value; | ||
} | ||
}); | ||
return every__default['default'](this.fields, function (field) { return field.hasValue; }); | ||
}, | ||
@@ -313,0 +320,0 @@ enumerable: false, |
{ | ||
"name": "factorial-form", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Factorial form library", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -33,2 +33,3 @@ import typescript from 'rollup-plugin-typescript2'; | ||
'lodash/isEqual', | ||
'lodash/every', | ||
'moment', | ||
@@ -35,0 +36,0 @@ 'flat', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40648
13
1039