Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
ampersand-input-view
Advanced tools
A view module for intelligently rendering and validating input. Works well with ampersand-form-view.
A view module for intelligently rendering and validating input. Works well with ampersand-form-view.
It does the following:
It's built on ampersand-view so it can be extended with extend
as you might expect.
npm install ampersand-input-view
var InputView = require('ampersand-input-view');
var field = new InputView({
// form input `name`
name: 'client_name',
// You can replace the built-in template with your own.
// just give it an html string. Make sure it has a single "root" element that contains:
// - an `<input>` or `<textarea>` element
// - 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)
template: // some HTML string
// Label name
label: 'App Name',
// Optional placeholder attribute
placeholder: 'My Awesome App',
// optinal intial value if it has one
value: 'hello',
// optional, this is the that will be
// replaced by this view. If you don't
// give it one, it will create one.
el: document.getElementByID('field'),
// whether or not this field is required
required: true, // true by default
// 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. They will be called
// in order with the current input value and you should
// write your test and return the error message to show
// if the test fails. It also gets called with the field
// 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 input. Works well with ampersand-form-view.
The npm package ampersand-input-view receives a total of 135 weekly downloads. As such, ampersand-input-view popularity was classified as not popular.
We found that ampersand-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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.