1.0.6 • Published 6 years ago

@yapsody/generic-validations v1.0.6

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 years ago

@yapsody/generic-validations

Generic validations built on top of Joi

Installation

npm i @yapsody/generic-validations --save

Usage

// require the entire library
const genericValidations = require('@yapsody/generic-validation');

// or require individual components
const { string, number, date } = require('@yapsody/generic-validations')

// using a validation to validate something
const { error, result } = genericValidations.number.positive.validate(1); // Success
const { error, result } = genericValidations.number.positive.validate('abc'); // Error

Available Validations

date

ValidationUsageDescription
timestampdate.timestamp.validate('2019-04-11T11:46:22.560Z')Check for a valid iso date time string
isodate.iso.validate('2019-04-19T09:09:40.826Z')Check for a valid iso date time string
isoWithNulldate.isoWithNull.validate('2019-04-19T09:09:40.826Z')Check for a valid iso date time string. Allow null value

number

ValidationUsageDescription
integernumber.integer.validate('123')Check for a valid integer number
positivenumber.positive.validate('123')Check for a valid positive integer number
precisionnumber.precision.validate('123')Check for a valid number with precision upto 3 decimal

string

ValidationUsageDescription
smallstring.small.validate('2019-04-11T11:46:22.560Z')Check for a string with length between 3 to 255
mediumstring.medium.validate('2019-04-11T11:46:22.560Z')Check for a string with length between 3 to 1000

Changelog

See the changelog page on Gitlab.

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago