![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ng2-validators
Advanced tools
An implementation of various angular validators for Angular 2.
List of validators
The rules are from https://github.com/vt-middleware/passay
The password validators are:
npm install ng2-validators
needs: ReactiveFormsModule
@import {PasswordValidators} from 'ng2-validators/ng2-validators'
...
password: Control = new Control('', Validators.compose([
PasswordValidators.repeatCharacterRegexRule(4),
PasswordValidators.whitespaceRule(),
PasswordValidators.alphabeticalCharacterRule(1);
PasswordValidators.digitCharacterRule(1);
PasswordValidators.lowercaseCharacterRule(1);
PasswordValidators.uppercaseCharacterRule(1);
PasswordValidators.allowedCharacterRule(['a', 'b']);
]));
@import {PasswordValidators} from 'ng2-validators/ng2-validators'
...
let password: FormControl = new FormControl('testPassword');
let confirmPassword: FormControl = new FormControl('testPassword');
let form = new FormGroup({
'newPassword': password,
'confirmPassword': confirmPassword
}, PasswordValidators.mismatchedPasswords()
);
@import {PasswordValidators} from 'ng2-validators/ng2-validators'
...
let password: FormControl = new FormControl('testPassword');
let confirmPassword: FormControl = new FormControl('testPassword');
let form = new FormGroup({
'testName': password,
'testName2': confirmPassword
}, PasswordValidators.mismatchedPasswords('testName', 'testName2' )
);
@import {EmailValidators} from 'ng2-validators/ng2-validators'
...
email: Control = new Control('', EmailValidators.normal());
email2: Control = new Control('', EmailValidators.simple());
@import {UniversalValidators} from 'ng2-validators/ng2-validators'
...
control: Control = new Control('', UniversalValidators.noWhitespace());
control: Control = new Control('', UniversalValidators.isNumber());
control: Control = new Control('', UniversalValidators.isInRange(2, 5));
control: Control = new Control('', UniversalValidators.minLength(2));
control: Control = new Control('', UniversalValidators.maxLength(7));
control: Control = new Control('', UniversalValidators.min(2));
control: Control = new Control('', UniversalValidators.max(2));
@import {CreditCardValidators} from 'ng2-validators/ng2-validators'
...
control: Control = new Control('', UniversalValidators.isCreditCard());
control: Control = new Control('', UniversalValidators.americanExpress());
control: Control = new Control('', UniversalValidators.dinersclub());
control: Control = new Control('', UniversalValidators.discover());
control: Control = new Control('', UniversalValidators.jcb());
control: Control = new Control('', UniversalValidators.maestro());
control: Control = new Control('', UniversalValidators.mastercard());
control: Control = new Control('', UniversalValidators.visa());
needs FormsModule and ValidatorsModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { ValidatorsModule } from 'ng2-validators/ng2-validators'
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule, FormsModule, ValidatorsModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
<form>
<input type="password" [(ngModel)]="model.password" name="password" #formControl="ngModel" password>
<p *ngIf="formControl.hasError('repeatCharacterRegexRule')">Password contains repeating characters</p>
<p *ngIf="formControl.hasError('digitCharacterRule')">Password should contain at least on digit</p>
<p *ngIf="formControl.hasError('alphabeticalCharacterRule')">Password should contain at least on alphabetical character</p>
<p *ngIf="formControl.hasError('lowercaseCharacterRule')">Password should contain at least on lowercase character</p>
<p *ngIf="formControl.hasError('uppercaseCharacterRule')">Password should contain at least on uppercase character</p>
</form>
// Override values
<input type="password" [(ngModel)]="model.password" name="password" #formControl="ngModel"
password
[repeatCharacter]="2"
[alphabeticalCharacter]="2"
[digitCharacter]="2"
[lowercaseCharacter]="2"
[uppercaseCharacter]="2"
>
<form>
<input type="text" [(ngModel)]="model.creditcard" name="creditcard" #formControl="ngModel" creditCard>
<p *ngIf="formControl.hasError('creditcard')">Is not a creditcard</p>
</form>
// Override values
// Test only for a specific creditcard
<input type="text" [(ngModel)]="model.creditcard" name="creditcard" #formControl="ngModel" [creditCard]="all|americanExpress|dinersclub|discover|jcb|maestro|mastercard|visa">
<form>
<input type="text" [(ngModel)]="model.email" name="email" #formControl="ngModel" email>
<p *ngIf="formControl.hasError('normalEmailRule')">Is not a email</p>
</form>
<form>
<input type="text" [(ngModel)]="model.firstname" name="firstname" #formControl="ngModel" noWhitespace>
<p *ngIf="formControl.hasError('noWhitespaceRequired')">Should not contain a whitespace</p>
</form>
<form>
<input type="number" [(ngModel)]="model.amount" name="amount" #formControl="ngModel" isNumber>
<p *ngIf="formControl.hasError('numberRequired')">Needs to be a number</p>
</form>
<form>
<input type="number" [(ngModel)]="model.amount" name="amount" #formControl="ngModel" isInRange [min]="2" [max]="4">
<p *ngIf="formControl.hasError('numberRequired')">Needs to be a number</p>
<p *ngIf="formControl.hasError('rangeValueToSmall')">Number to small</p>
<p *ngIf="formControl.hasError('rangeValueToBig')">Number to big</p>
</form>
<form>
<input type="number" [(ngModel)]="model.amount" name="amount" #formControl="ngModel" [min]="2">
<p *ngIf="formControl.hasError('numberRequired')">Needs to be a number</p>
<p *ngIf="formControl.hasError('min')">Number to small</p>
</form>
<form>
<input type="number" [(ngModel)]="model.amount" name="amount" #formControl="ngModel" [max]="2">
<p *ngIf="formControl.hasError('numberRequired')">Needs to be a number</p>
<p *ngIf="formControl.hasError('max')">Number to small</p>
</form>
##Todo
Get the complete changelog here: https://github.com/Nightapes/ng2-validators/releases
FAQs
An implementation of angular validators for Angular 2
The npm package ng2-validators receives a total of 24 weekly downloads. As such, ng2-validators popularity was classified as not popular.
We found that ng2-validators 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.