
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
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.
The npm package ampersand-array-input-view receives a total of 4 weekly downloads. As such, ampersand-array-input-view popularity was classified as not popular.
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.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.