New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

ampersand-input-view

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-input-view - npm Package Compare versions

Comparing version

to
4.0.2

@@ -147,3 +147,3 @@ /*$AMPERSAND_VERSION*/

var message = '';
if (this.required && !this.value) {
if (this.required && this.value === '') {
return this.requiredMessage;

@@ -150,0 +150,0 @@ } else {

{
"name": "ampersand-input-view",
"description": "A view module for intelligently rendering and validating input. Works well with ampersand-form-view.",
"version": "4.0.1",
"version": "4.0.2",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "browserify": {

@@ -62,3 +62,3 @@ # ampersand-input-view

// call its parent's initialize manually
AmpersandInputView.prototype.initialize.call(apply, arguments);
AmpersandInputView.prototype.initialize.apply(this, arguments);

@@ -174,3 +174,3 @@ // do whatever else you need to do on init here

// call parent constructor
AmpersandInputView.prototype.initialize.call(apply, arguments);
AmpersandInputView.prototype.initialize.apply(this, arguments);

@@ -177,0 +177,0 @@ // listen for changes to input value

@@ -158,2 +158,30 @@ var test = require('tape');

test('value `0` should be treated as a valid value if required is set to true', function(t) {
var input = new InputView({
name: 'title',
type: 'number',
value: 0,
required: true
});
input.render();
var inputElement = input.el.querySelector('input');
var messageContainer = input.el.querySelector('[data-hook=message-container]');
t.ok(isHidden(messageContainer), 'Message should not be visible');
inputElement.value = 1;
input.handleInputChanged();
input.handleChange();
t.ok(isHidden(messageContainer), 'Message should not be visible');
inputElement.value = 0;
input.handleInputChanged();
input.handleChange();
t.ok(isHidden(messageContainer), 'Message should not be visible');
t.end();
});
test('Tests with required true and false', function (t) {

@@ -160,0 +188,0 @@ var inputs = [