1.0.23 • Published 6 years ago
@yapsody/lib-validations v1.0.23
@yapsody/generic-validations
Yap validations built on top of Joi and Generic Validations
Installation
npm i @yapsody/yap-validations --saveUsage
// 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'); // ErrorAvailable Validations
Account
| Validation | Usage | Description |
|---|---|---|
| amount | account.amount.validate(20000) | Check for a valid amount when fee type is 1 |
| feeType | account.feeType.validate(1) | Check for a valid fee type which must be positive integer. Only 1 & 2 are valid. |
Code table
| Validation | Usage | Description |
|---|---|---|
| identifierColumn | codeTable.identifierColumn.validate('identifier') | Check for a string with max length 255 |
| data | codeTable.data.validate('Data in any format or type is valid') | Check for data of any type |
| type | codeTable.type.validate('Some String') | Check for a type with length between 3 to 255 |
Code template
| Validation | Usage | Description |
|---|---|---|
| condition | codeTemplate.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 |
| conditionType | codeTemplate.conditionType.validate(1) | Check for positive integer from 0, 1 & 2 |
| value | codeTemplate.value.validate('Any string') | Check for a string with no whitespaces before or after string and max length 255 |
Taxes
| Validation | Usage | Description |
|---|---|---|
| absorbInPrice | tax.absorbInPrice.validate(1) | Check for positive integer from 0 & 1 |
| boxOffice | tax.boxOffice.validate(1) | Check for positive integer from 0 & 1 |
| daysBeforeEnd | tax.daysBeforeEvent.validate(12) | Check for positive integer |
| interfaceId | tax.interfaceId.validate(1, 2) | Check for array of integer from 1 & 2 as interface id |
| itemIds | tax.itemIds.validate(1, 2, 3) | Check for array of positive integer as ids |
| itemLinks | tax.itemLinks.validate(1) | Check for positive integer from 0 & 1 |
| itemTypeName | tax.itemTypeName.validate('Item name') | Check for string name with max length 55 |
| linkItems | tax.linkItems.validate(1) | Check for any positive integer from 0 & 1 |
| linkOnlineStore | tax.linkOnlineStore.validate(1) | Check for any positive integer from 0 & 1 |
| linkType | tax.linkType.validate({id: 1, name: 'name'}) | Check for object with id & name for link type |
| onlineStore | tax.onlineStore.validate(1) | Check for any positive integer from 0 & 1 |
| search | tax.search.validate('any string') | Check for a string to search |
| startDateOption | tax.startDateOption.validate(1) | Check for any integer from 0, 1 & 2 |
| amount | surcharge.amount.validate(3) | Check for a valid number with precision upto 3 decimal |
| feeType | surcharge.feeType.validate(2) | Check for a valid fee type code 1, 2, it is optional and default 1 |
User
| Validation | Usage | Description |
|---|---|---|
| user.email.validate('development@yapsody.com') | Check for string with max length 255 and no unicode | |
| password | user.password.validate('Password@1234') | Check for string with min length 8 and max length 128 |
| token | user.token.validate('String') | Check for any string |
common
| Validation | Usage | Description |
|---|---|---|
| id | common.id.validate(1) | Check for a valid id |
| status | common.status.validate(3) | Check for a valid status code 0, 1, 2, 3, 4 |
| name | common.name.validate('Name') | Check for a string with max length 55 as name |
| description | common.description.validate('Some description') | Check for a string with no whitespaces before or after string and max length 255 |
| searchQuery | common.searchQuery.validate('Some description') | Check for a string with no whitespaces before or after string and max length 255 |
| tag | common.tag.validate('Some description') | Check for a string with no whitespaces before or after string and max length 56, min length 1 |
| holdCode | common.holdCode.validate('hold1') | Check for a string with no special characters and no whitespaces before or after and max length 8, min length 1 |
| phoneNo | common.phoneNo.validate('+1 (1234)-456-7890') | Check for a valid phone number which can be alphabets |
event
| Validation | Usage | Description |
|---|---|---|
| display | event.display.validate(0) | Check for a valid display code 0, 1 |
| displayMessageOption | event.displayMessageOption.validate(0) | Check for a valid message display option 1, 2 |
| isLive | event.isLive.validate(0) | Check for a valid is-live code 0, 1 |
language customization
| Validation | Usage | Description |
|---|---|---|
| direction | languageCustomization.direction.validate(2) | Check for a valid is-live code 1, 2 |
| identifier | languageCustomization.identifier.validate('yash') | Check for a valid identifier having length not greater than 256 |
page
| Validation | Usage | Description |
|---|---|---|
| number | page.number.validate(1) | Check for a valid positive integer number |
| size | page.size.validate(1) | Check for a valid positive integer number |
session
| Validation | Usage | Description |
|---|---|---|
| body | session.body.validate('yash') | Check for a valid body string having length between 3 to 255 |
sort
| Validation | Usage | Description |
|---|---|---|
| by | sort.by.validate('column') | Check for a valid column name string |
| order | sort.order.validate('DESC') | Check for a valid sort order 'asc', 'desc' |
surcharge
| Validation | Usage | Description |
|---|---|---|
| absorbInPrice | surcharge.absorbInPrice.validate(1) | Check for a valid absorb in price 0, 1 |
| amount | surcharge.amount.validate(3) | Check for a valid number with precision upto 3 decimal |
| body | surcharge.body.validate('yash') | Check for a valid body string having length between 3 to 255 |
| boxOffice | surcharge.boxOffice.validate(0) | Check for a valid box office positive integer 0, 1 |
| daysBeforeEvent | surcharge.daysBeforeEvent.validate(2) | Check for a valid integer which is optional |
| description | surcharge.description.validate('yashyash') | Check for a valid description string having length not greater than 255, empty string allowed |
| feeType | surcharge.feeType.validate(2) | Check for a valid fee type code 1, 2, it is optional and default 1 |
| interfaceId | surcharge.interfaceId.validate(1, 2) | Check for a valid interface id array, valid integers in an array (0, 1) |
| itemLink | surcharge.itemLink.validate(0) | Check for a valid item link 0, 1 which is optional |
| itemTypeName | surcharge.itemTypeName.validate('yashyash') | Check for a valid name having length not greater than 257 |
| linkBoxOffice | surcharge.linkBoxOffice.validate(0) | Check for a valid link box office code 0, 1, default 1 |
| linkOnlineStore | surcharge.linkOnlineStore.validate(0) | Check for a valid link box office code 0, 1, default 1 |
| onlineStore | surcharge.onlineStore.validate(0) | Check for a valid online store code integer 0, 1 |
| startDateOption | surcharge.startDateOption.validate(2) | Check for a valid start date option integer 1, 2, 3 |
user code
| Validation | Usage | Description |
|---|---|---|
| archived | userCode.archived.validate(0) | Check for a valid archived code min 0 max 1 |
| identifier | userCode.identifier.validate('test') | Check for a valid string |
Inventory
Changelog
See the changelog page on Gitlab.
1.0.23
6 years ago