ng-error-messages
A library that help you show error messages based in rules validation. Based in repository of my partner Arthur
Demo
https://ouracademy.github.io/error-messages/
Reason
Tired to always write this in your angular app:
Field is required
And repeat this to every field in every form in every view.
So you can instead do this:
And it will do the same in very uniform way in all your fields in every forms in all your views. This package will create validation messages for you. It contains predefined validation messages.
Installation
Install the npm module by running:
npm install ng-error-messages --save
Usage
You can see the demo app to have a more detail of the usage.
ErrorMessageModule
:
1. Import the ;;;;;
2. Init the DisplayErrorService for your application:
;;
3. Use it on your template:
Messager for errors
Validators
This is the list of the supported validations
angular built-in validators
- required
- minlength
- maxlength
- pattern
- min
- max
Customizing
At this moment only support alias for every field. TODO: Customize messages for error type.
Development
Prepare your environment
- Install Node.js and NPM (should come with)
- Install local dev dependencies:
npm install
while current directory is this repo
Development server
Run npm start
to start a development server on port 8000 with auto reload + tests.
Testing
Run npm test
to run tests once or npm run test:watch
to continually run tests.
Release
- Bump the version in package.json (once the module hits 1.0 this will become automatic)
npm run release
TODO
This package it's creating on free times after university...and theses... For now works with Reactive Driven Forms, it wasn't tested with Template Driven Forms. Probably it will work, if work send us a message.