1.0.23 • Published 4 years ago

@yapsody/lib-validations v1.0.23

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

@yapsody/generic-validations

Yap validations built on top of Joi and Generic Validations

Installation

npm i @yapsody/yap-validations --save

Usage

// require the entire library
const yapValidations = require('@yapsody/yap-validation');

// or require individual components
const { generic, common, user } = require('@yapsody/yap-validations')

// using a validation to validate something
const { error, result } = yapValidations.common.id.validate(1); // Success
const { error, result } = yapValidations.common.id.validate('abc'); // Error

Available Validations

Account

ValidationUsageDescription
amountaccount.amount.validate(20000)Check for a valid amount when fee type is 1
feeTypeaccount.feeType.validate(1)Check for a valid fee type which must be positive integer. Only 1 & 2 are valid.

Code table

ValidationUsageDescription
identifierColumncodeTable.identifierColumn.validate('identifier')Check for a string with max length 255
datacodeTable.data.validate('Data in any format or type is valid')Check for data of any type
typecodeTable.type.validate('Some String')Check for a type with length between 3 to 255

Code template

ValidationUsageDescription
conditioncodeTemplate.condition.validate({ column_id: 2, condition_id: 2, value_1: 'string', value_2: 'string'})Check for array with items column id, condition id, value 1, value 2
conditionTypecodeTemplate.conditionType.validate(1)Check for positive integer from 0, 1 & 2
valuecodeTemplate.value.validate('Any string')Check for a string with no whitespaces before or after string and max length 255

Taxes

ValidationUsageDescription
absorbInPricetax.absorbInPrice.validate(1)Check for positive integer from 0 & 1
boxOfficetax.boxOffice.validate(1)Check for positive integer from 0 & 1
daysBeforeEndtax.daysBeforeEvent.validate(12)Check for positive integer
interfaceIdtax.interfaceId.validate(1, 2)Check for array of integer from 1 & 2 as interface id
itemIdstax.itemIds.validate(1, 2, 3)Check for array of positive integer as ids
itemLinkstax.itemLinks.validate(1)Check for positive integer from 0 & 1
itemTypeNametax.itemTypeName.validate('Item name')Check for string name with max length 55
linkItemstax.linkItems.validate(1)Check for any positive integer from 0 & 1
linkOnlineStoretax.linkOnlineStore.validate(1)Check for any positive integer from 0 & 1
linkTypetax.linkType.validate({id: 1, name: 'name'})Check for object with id & name for link type
onlineStoretax.onlineStore.validate(1)Check for any positive integer from 0 & 1
searchtax.search.validate('any string')Check for a string to search
startDateOptiontax.startDateOption.validate(1)Check for any integer from 0, 1 & 2
amountsurcharge.amount.validate(3)Check for a valid number with precision upto 3 decimal
feeTypesurcharge.feeType.validate(2)Check for a valid fee type code 1, 2, it is optional and default 1

User

ValidationUsageDescription
emailuser.email.validate('development@yapsody.com')Check for string with max length 255 and no unicode
passworduser.password.validate('Password@1234')Check for string with min length 8 and max length 128
tokenuser.token.validate('String')Check for any string

common

ValidationUsageDescription
idcommon.id.validate(1)Check for a valid id
statuscommon.status.validate(3)Check for a valid status code 0, 1, 2, 3, 4
namecommon.name.validate('Name')Check for a string with max length 55 as name
descriptioncommon.description.validate('Some description')Check for a string with no whitespaces before or after string and max length 255
searchQuerycommon.searchQuery.validate('Some description')Check for a string with no whitespaces before or after string and max length 255
tagcommon.tag.validate('Some description')Check for a string with no whitespaces before or after string and max length 56, min length 1
holdCodecommon.holdCode.validate('hold1')Check for a string with no special characters and no whitespaces before or after and max length 8, min length 1
phoneNocommon.phoneNo.validate('+1 (1234)-456-7890')Check for a valid phone number which can be alphabets

event

ValidationUsageDescription
displayevent.display.validate(0)Check for a valid display code 0, 1
displayMessageOptionevent.displayMessageOption.validate(0)Check for a valid message display option 1, 2
isLiveevent.isLive.validate(0)Check for a valid is-live code 0, 1

language customization

ValidationUsageDescription
directionlanguageCustomization.direction.validate(2)Check for a valid is-live code 1, 2
identifierlanguageCustomization.identifier.validate('yash')Check for a valid identifier having length not greater than 256

page

ValidationUsageDescription
numberpage.number.validate(1)Check for a valid positive integer number
sizepage.size.validate(1)Check for a valid positive integer number

session

ValidationUsageDescription
bodysession.body.validate('yash')Check for a valid body string having length between 3 to 255

sort

ValidationUsageDescription
bysort.by.validate('column')Check for a valid column name string
ordersort.order.validate('DESC')Check for a valid sort order 'asc', 'desc'

surcharge

ValidationUsageDescription
absorbInPricesurcharge.absorbInPrice.validate(1)Check for a valid absorb in price 0, 1
amountsurcharge.amount.validate(3)Check for a valid number with precision upto 3 decimal
bodysurcharge.body.validate('yash')Check for a valid body string having length between 3 to 255
boxOfficesurcharge.boxOffice.validate(0)Check for a valid box office positive integer 0, 1
daysBeforeEventsurcharge.daysBeforeEvent.validate(2)Check for a valid integer which is optional
descriptionsurcharge.description.validate('yashyash')Check for a valid description string having length not greater than 255, empty string allowed
feeTypesurcharge.feeType.validate(2)Check for a valid fee type code 1, 2, it is optional and default 1
interfaceIdsurcharge.interfaceId.validate(1, 2)Check for a valid interface id array, valid integers in an array (0, 1)
itemLinksurcharge.itemLink.validate(0)Check for a valid item link 0, 1 which is optional
itemTypeNamesurcharge.itemTypeName.validate('yashyash')Check for a valid name having length not greater than 257
linkBoxOfficesurcharge.linkBoxOffice.validate(0)Check for a valid link box office code 0, 1, default 1
linkOnlineStoresurcharge.linkOnlineStore.validate(0)Check for a valid link box office code 0, 1, default 1
onlineStoresurcharge.onlineStore.validate(0)Check for a valid online store code integer 0, 1
startDateOptionsurcharge.startDateOption.validate(2)Check for a valid start date option integer 1, 2, 3

user code

ValidationUsageDescription
archiveduserCode.archived.validate(0)Check for a valid archived code min 0 max 1
identifieruserCode.identifier.validate('test')Check for a valid string

Inventory

Changelog

See the changelog page on Gitlab.

1.0.23

4 years ago