Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@ngx-smart-forms/smart-input-type
Advanced tools
"@ngx-smart-forms/smart-input-type" is an Angular directive that enhances native input elements by providing advanced validation and formatting capabilities. It supports predefined types like alphanumeric, numeric, email, and custom regex patterns, while
The SmartInputType
directive enhances the native HTML input element by providing additional validation and formatting capabilities. It allows developers to define a specific input behavior, such as allowing only alphanumeric characters, enforcing email format, or creating custom validation patterns, while supporting native HTML input types like text
, email
, url
, etc.
alphanumeric
, numeric
, alpha
, email
, url
, tel
and custom patterns.text
, email
, password
), allowing for flexibility when combining smartType
with standard HTML types.Check out a live interactive demo of the @ngx-smart-forms/smart-input-type
library on StackBlitz:
You can also click here to open the project in a new tab.
To install the library, use npm:
npm install @ngx-smart-forms/smart-input-type
Or use Yarn:
yarn add @ngx-smart-forms/smart-input-type
To use @ngx-smart-forms/smart-input-type
, import the SmartInputType
into your Angular application
import { Component } from '@angular/core';
import { SmartInputType } from '@ngx-smart-forms/smart-input-type';
@Component({
standalone: true, // Indicate that this is a standalone component
imports: [SmartInputType], // Import necessary modules
...
})
export class MyFormComponent { }
<input smartType="alphanumeric" />
This input will only allow alphanumeric characters (letters and numbers).
You can use smartType
in conjunction with native HTML types:
<input type="text" smartType="alpha" />
The input will only allow alphabetic characters but will still behave as a text input type.
Alternatively, you can apply smartType
directly to a native HTML type, like a password field:
<input smartType="password" />
This will function as a password field but maintain its native behavior.
<input smartType="alphanumeric" [acceptSpace]="true" />
Allows alphanumeric characters along with spaces.
<input smartType="alpha" case="uppercase" />
Automatically converts the input to uppercase.
<input smartType="text" languageSet="es" />
Restricts the input to Spanish alphabet characters (a-zA-Záéíóúñ).
Alternatively, you can apply the language character set directly to the languageSet
attribute:
<input smartType="text" [languageSet]="'٠١٢٣٤٥٦٧٨٩'" />
This will restricts the input to arabic numerals.
<input smartType="pattern" pattern="a-zA-Z0-9" />
Applies a custom regex pattern for validation.
<input smartType="alphanumeric" [debounceTime]="300" />
Debounces input events by 300 milliseconds, improving performance during rapid input changes.
The SmartInputType
directive supports several predefined smart types:
alphanumeric
: Allows letters and numbers. Spaces can be optionally allowed using [acceptSpace]="true"
.alpha
: Allows only letters. Optionally allow spaces with [acceptSpace]="true"
.numeric
: Allows only numbers. Spaces can be allowed using [acceptSpace]="true"
.email
: Enforces strict email validation.url
: Enforces strict URL validation.tel
: Enforces strict telephone number validation.pattern
: Allows custom regex patterns to be applied.text
, password
, number
, email
, etc.The directive integrates with Angular’s form controls to provide error feedback. If validation fails, the directive will set appropriate errors on the form control.
For example, errors like strictEmail
, strictUrl
, and strictTel
can be applied, depending on the validation type.
You can access these errors in your component to provide user feedback:
if (myForm.get('email').hasError('strictEmail')) {
// Handle email validation error
}
Property | Type | Default | Description |
---|---|---|---|
smartType | string | '' | Specifies the type of input validation (e.g., alphanumeric , numeric , alpha , etc.). |
acceptSpace | boolean | false | Whether to accept spaces in the input (only for alphanumeric , numeric and alpha ). |
case | 'uppercase' 'lowercase' null | null | Transforms the input value to uppercase or lowercase. |
languageSet | string | null | Defines the language set for allowed characters (e.g., en, es, fr). |
debounceTime | number | 0 | Delay in milliseconds before applying the validation (useful for handling input events efficiently). |
pattern | string null | null | Custom regex pattern for validation (applies only when smartType="pattern" ). |
smartType
is provided, a warning will be displayed in the console.smartType
is incompatible with the native input element’s type (e.g., trying to apply numeric
on a tel
input), a warning will be issued.smartType
or other properties, re-validating the input when the values change.When validation fails, the directive applies the .has-error
class to the input element, allowing for easy styling of invalid fields. You can style the error state in your CSS as follows:
input.has-error {
border-color: red;
}
If you encounter an issue, you can create a ticket
We welcome contributions! Please see the CONTRIBUTING.md file for more information on how to get involved.
This library is licensed under the MIT License - see the LICENSE file for details.
FAQs
"@ngx-smart-forms/smart-input-type" is an Angular directive that enhances native input elements by providing advanced validation and formatting capabilities. It supports predefined types like alphanumeric, numeric, email, and custom regex patterns, while
We found that @ngx-smart-forms/smart-input-type demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.