Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mw-error-messages

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mw-error-messages

angular wrapper for input validation

  • 1.2.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

mw-error-messages

mw-error-messages is an AngularJS module that wrap the ngMessage into a easy to use directive for error validation. It has several features like an icon in the input field or to show that a field is valid and invalid.

Requirements (tested in)

  • Angular (v1.6.6)
  • NgMessages (v1.6.6)
  • Bootstrap (v3.3.7) used as default grid system
  • (Optional) FontAwsome (4.3.0) or another font if you want to use icons
  • (Optional) ui-bootstrap (2.5.0)

Install

You can install this package either with npm or with bower.

npm

npm install mw-error-messages --save

bower

bower install mw-error-messages

Usage

Once the script is included in your html file, simply include the module in your app:

angular.module('myApp', ['ngMessages', 'mw-error-message']);

And use the included 'mwErrorMessage' directive thusly:

<div mw-error-message="CTRLSYSTEM_">
    <input title="" type="text" name="test" ng-model="model.test" class="form-control" required/>
</div>

The content of mw-error-message is used as the label or if you use a translation directive its used as a prefix combined with the name of the input field. In this example the marker would be 'CTRLSYSTEM_TEST'.

If you use the required attribute, a '*' will be placed behind the label to mark this field as required. This also works with ng-required.

Config

NameTypeDescription
iconbooleanUse icons or not
icon_templatestringDefine the icon template
successbooleanShow success or not
label_classesarraySet label classes
div_inner_classesarraySet inner div classes
div_outer_classesarraySet additional outer div classes
help_block_classesarraySet help block classes
additional_help_blockstringTemplate for addtional help block
messagesarrayAssociative array. Key field are the "when directive" value is the message.
translatebooleanShould the translate filter be used

icon, success and addtional_help_block can be changed in the html like:

<div mw-error-message="CTRLSYSTEM_" mw-error-message-options="mwOptions">
    <input title="" type="text" name="test" ng-model="model.test" required/>
</div>
$scope.mwOptions = {
    icon: true,
    tooltip: true,
    success: true,
    addHelp: '<span>Additional Help block</span>'
};

If you want to use other Font icons just override this:

.has-success .wm_error_message_icon:after{
	content: "\f00c";
}
.has-error .wm_error_message_icon:after{
	content: "\f00d";
}

If you want to use more messages or change the content of the default message:

// override default message
mwConfig.messages['required'] = 'This field is required';
//add a new message
mwConfig.messages['birthday'] = 'You need to be 18 years old.';

Demo

View demo on Plunker

Tasklist

  • add more examples
  • add documentation
  • nodejs, bower support
  • fix spelling, grammar mistakes

Keywords

FAQs

Package last updated on 06 Nov 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc