https://github.com/chandru415/ngx-requisite
Angular custom validators & utility functions
https://github.com/chandru415/ngx-requisite
angular ngx reactiveform-validation reactiveforms require validation
Last synced: 10 months ago
JSON representation
Angular custom validators & utility functions
- Host: GitHub
- URL: https://github.com/chandru415/ngx-requisite
- Owner: chandru415
- License: mit
- Created: 2021-12-18T09:51:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-18T08:24:10.000Z (over 3 years ago)
- Last Synced: 2025-07-02T20:14:17.194Z (12 months ago)
- Topics: angular, ngx, reactiveform-validation, reactiveforms, require, validation
- Language: TypeScript
- Homepage:
- Size: 1.21 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NgxRequisite
ngx-requisite library - custom Validators, Utility functions for common development.


# Installation
```bash
npm i @slck/ngx-requisite --save
```
# Methods
- isNullOrUndefined
- isDate
- isObject
- leadZeroForMonthOrDay
- remainingDaysHoursFormTwoDates
- toCamelCaseKeys
# Validators
## Requisite validators
- whitespace
- isNegative
- decimalPrecision
# Usage
## Model driven
import `ReactiveFormsModule` in *app.module.ts*
```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule, ReactiveFormsModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
```
ngx-requisite
import `CustomValidators` in *app.component.ts*
```typescript
import { Component } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { requisiteValidators } from '@slck/ngx-requisite';
@Component({
selector: 'app',
template: require('./app.html')
})
export class AppComponent {
devForm = this.fb.group({
userName: ['', [requisiteValidators.whitespace]],
});
get controls(){
return this.devForm.controls;
}
constructor(private fb: FormBuilder) {}
}
```
```html
having space
```
### isNegative
```typescript
new FormControl('', requisiteValidators.isNegative)
```
### decimalPrecision
```typescript
new FormControl('',requisiteValidators.decimalPrecision)
```
### toCamelCaseKeys
```typescript
import { toCamelCaseKeys } from '@slck/ngx-requisite';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
ngOnInit(): void {
const uncap = toCamelCaseKeys({
Name: '@slck/ngx-requisite',
Address: {
Home: 'uhi'
},
Urls: [
{Path: 'google', Location: 'us'}
]
})
}
}
-- output:
{
name: '@slck/ngx-requisite',
address: {
home: 'uhi'
},
urls: [
{Path: 'google', Location: 'us'}
]
}
```
# For developers
To run the project : `npm start`
Don't forget to run `npm test` and `npm lint` before each pull request. Thanks !