@sds-stream/function-validations
v1.0.21
Published
Shared functions for CANApps by Stream Data Systems
Readme
- First and Last Name Validations: Ensures names contain only alphabetical characters and conform to accepted standards.
- Username Validation: Validates usernames based on length, allowed characters, and restricted symbols.
- Email Validation: Ensures email addresses adhere to standard format and structure.
- Phone Number Validation: Validates phone numbers to match standard formats and character restrictions.
- Password Validation: Checks if input meets strong password criteria, such as minimum length and character variety.
- All validation functions return an object detailing if an error exists hasError and an associated errorMessage for intuitive error handling.
- Functions like checkBoolType() and checkStringType() offer runtime type verification to prevent unintended data types from causing errors in applications.
- With the VALID_MSG object, developers have a centralized repository of validation error messages, ensuring consistent feedback across the application.
- In-depth documentation ensures developers have all the information required to effectively leverage the library's capabilities
npm install @sds-stream/function-validationsImport required functions from the @sds-stream/function-validations
import { validateFirstName } from '@sds-stream/function-validations';
import { validateLastName } from '@sds-stream/function-validations';
import { validateEmail } from '@sds-stream/function-validations';
import { validateUsername } from '@sds-stream/function-validations';
import { validatePassword } from '@sds-stream/function-validations';
import { validatePhones } from '@sds-stream/function-validations';
import { VALID_MSG } from '@sds-stream/function-validations';var { validateUsername } = require('@sds-stream/function-validations');
function func_name() {
var inputUsername = '[email protected]';
var res = validateUsername(inputUsername);
console.log('hasError :>> ', res.hasError); // true or false
console.log('errorMessage :>> ', res.errorMessage); // "Error messages..."
}var { VALID_MSG } = require('@sds-stream/function-validations');
function func_name() {
console.log(VALID_MSG.SELECTOR_REQUIRED);
// Result : "At least one option must be selected."
}import { validateUsername } from '@sds-stream/function-validations';
const func_name = () => {
const inputUsername = '[email protected]';
const res = validateUsername(inputUsername);
console.log('hasError :>> ', res.hasError); // true or false
console.log('errorMessage :>> ', res.errorMessage); // "Error messages..."
};import { VALID_MSG } from '@sds-stream/function-validations';
const func_name = () => {
console.log(VALID_MSG.SELECTOR_REQUIRED);
// Result : "At least one option must be selected."
};