
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Lightweight and highly configurable boostrap validator built on-top of validator.js.
var validator = new Dominar($('form'), {
email: {
rules: 'required|email'
},
username: {
rules: 'required|min:3|max:10',
triggers: ['keyup', 'change', 'focusout'],
delay: 300
}
});
Note: See below for all possible options. Only rules
is required.
http://garygreen.github.io/dominar/
bower install dominar --save
The main file to include is dist/dominar-standalone.js
. If you already have validator.js installed then just simply use dist/dominar.js
By default it is assumed your element is contained inside a .form-group
<div class="form-group">
<label>Username</label>
<input type="text" name="username"/>
</div>
You can change this by supplying the container
option e.g. container: 'td'
accepted
alpha
alpha_dash
alpha_num
confirmed
digits:value
different:attribute
email
in:foo,bar,..
integer
max:value
not_in:foo,bar,..
numeric
required
same:attribute
size:value
url
regex:pattern
See here for more rules & usage details.
Add a custom validation rule:
Dominar.register('uppercase', function(value) {
return value.toUpperCase() === value;
}, 'The :attribute must only be uppercase.');
Use remoteRule
which takes a deferred object (like $.ajax
and $.get
returns).
var dominar = new Dominar($('form'), {
username: {
rules: 'required',
remoteRule: function(desiredUsername) {
return $.get('/api/check-username', { username: desiredUsername });
}
}
});
On your server return HTTP status code 200 if validation passes or if not, a 4xx
json response with the error message:
{"message": "Username already taken."}
By default error messages are automatically generated for you. If you would like to customise, use the customMessages
option to specify a custom error message for the rules.
username: {
rules: 'required|min:5',
customMessages: {
required: 'Whoops, :attribute field is required!',
min: 'This needs more characters :('
}
}
Just manually add anywhere inside your .form-group
a .help-block
and dominar will automatically detect and use.
<div class="form-group">
<div class="help-block"></div>
<input type="text" name="username"/>
</div>
Note: by default dominar will automatically add errors message straight after the input
element.
If you want to change the default options you can simply overwrite on the prototype like in the below example. This is useful if you want to always use e.g. fontawesome icons instead of glyphicons. Of course these are just defaults and can still be customised on a per-field level.
Dominar.prototype.defaults = $.extend({}, Dominar.prototype.defaults, {
feedbackIcons: {
error: '<i class="fa fa-remove"></i>',
success: '<i class="fa fa-check"></i>'
}
});
Option | Type | Description |
---|---|---|
rules | string | Set of rules seperated by pipe |
triggers | array/false | Determines when validation will be triggered on element. Set to false to turn off automatic triggering. |
delay | integer/false | Delay in triggering validation when typing in a field. Set to false to always trigger validation as soon as possible. |
delayTriggers | array | Determines when validation will be triggered as a delay on element. |
container | string | The selector for the element container |
message | boolean | Whether to display error messages or not |
customMessages | object | Set custom error messages for the rules |
feedback | boolean | Whether to display feedback icon or not |
feedbackIcons | object | Configure the success and error feedback icons |
remoteRule | function | Asynchronous rule to run |
Dominar will fire various events on the form
. You can listen for the events like:
$('#my-form').bind('dominar.init-field', function(event) {
var dominar = event.dominar;
var field = event.dominarField; // The DominarField which has been initialized
});
The submit
event allows you to prevent the validation from occuring by preventing the default action:
$('#my-form').bind('dominar.submit', function(event) {
event.preventDefault(); // Prevent form from being validated
});
Name | Preventable | Description |
---|---|---|
dominar.init-field | No | When a DominarField has been initialized (useful for adding additional event listeners to the input element etc) |
dominar.submit | Yes | When form is about to be submitted and before validation check has been run. |
dominar.submit-passed | Yes | When form passed validation and is about to be submitted. |
dominar.submit-failed | No | When failed validation check when form was attempted to be submitted. |
FAQs
Lighweight and highly configurable bootstrap validator
The npm package dominar receives a total of 0 weekly downloads. As such, dominar popularity was classified as not popular.
We found that dominar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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 uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.