Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ampersand-array-input-view
Advanced tools
A view module for intelligently rendering and validating inputs that should produce an array of values. Works well with ampersand-form-view.
Lead Maintainer: Michael Garvin
A view module for intelligently rendering and validating inputs that should produce an array of values. Works well with ampersand-form-view.
It does the following:
npm install ampersand-array-input-view
The only required attribute is a name. Everything else is optional.
var InputView = require('ampersand-array-input-view');
var field = new InputView({
// form input's `name` attribute
name: 'client_name',
// You can replace the built-in template for the parent item
// just give it an html string. Make sure it has a single "root" element that contains:
// - an element with a `data-hook="label"` attribute
// - an element with a `data-hook="fieldContainer"` this is where individual fields go
// - an element with a `data-hook="main-message-container"` attribute (this we'll show/hide)
// - an elememt with a `data-hook="main-message-text"` attribute (where message text goes for error)
template: // some HTML string,
// Template for individual view. It should be a string of HTML
// Make sure it has a single "root" element that contains
// - an element with a `data-hook="label"` attribute
// - an element with a `data-hook="message-container"` attribute (this we'll show/hide)
// - an elememt with a `data-hook="message-text"` attribute (where message text goes for error)
fieldTemplate // HTML string
// Label name
label: 'App Name',
// Optional placeholder attribute
placeholder: 'My Awesome App',
// optional intial value if it has one
value: ['hello'],
// optional, this is the element that will be
// replaced by this view. If you don't
// give it one, it will create one.
el: document.getElementByID('field'),
// use min/max length to set how many answers
// are required
minLength: 0,
maxLength: 10,
// class to set on input when input is valid
validClass: 'input-valid', // <- that's the default
// type value to use for the input tag's type value
type: 'text',
// class to set on input when input is valid
invalidClass: 'input-invalid', // <- that's the default
// Message to use if error is that it's required
// but no value was set.
requiredMessage: 'This field is required.',
// An array of test functions that each input must pass.
// They will be called in order with the current input value
// and you should write your test to return an error message
// if it fails and something falsey if it passes.
// Note that these tests get called with the field view instance as
// it's `this` context.
tests: [
function (val) {
if (val.length < 5) return "Must be 5+ characters.";
}
],
// optional, you can pass in the parent view explicitly
parent: someViewInstance
});
// append it somewhere or use it in side an ampersand-form-view
document.querySelector('form').appendChild(field.el);
Created by @HenrikJoreteg.
MIT
FAQs
A view module for intelligently rendering and validating inputs that should produce an array of values. Works well with ampersand-form-view.
We found that ampersand-array-input-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.