PHP Classes

File: Rules-For-Custom-DataTypes-Configuration.md

Recommend this page to a friend!
  Packages of Ramesh Narayan Jangid (Sharma)   Open Swoole Microservices   Rules-For-Custom-DataTypes-Configuration.md   Download  
File: Rules-For-Custom-DataTypes-Configuration.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Open Swoole Microservices
Implement microservices using Open Swoole
Author: By
Last change: refactor
Date: 24 days ago
Size: 2,736 bytes
 

Contents

Class file image Download

Custom DataTypes

Defining Custom DataTypes

The custom data types key's are classified in two sections depending on key's - Required / Optional key's

Required

dataType

This can take one fo the PHP data type (bool, int, float, string). This is a required key.

Optional

canBeNull

This represents the Custom DataType can be NULL. This is an optional key.

minValue

This represents the minimum value of the Custom DataType. This is an optional key.

maxValue

This represents the maximum value of the Custom DataType. This is an optional key.

minLength

This represents the minimum length of the Custom DataType. This is an optional key.

maxLength

This represents the maximum length of the Custom DataType. This is an optional key.

enumValues

This represents Custom DataType should have any one value from the defined array. This is an optional key.

setValues

This represents Custom DataType should have values belonging in this array. This is an optional key.

regex

This represents Custom DataType should pass this regular expression. This is an optional key.

Custom DataTypes Example

public static $CustomINT = [

// Required param
	// PHP data type (bool, int, float, string)
	'dataType' => 'int',

// Optional params
	// Value can be null
	'canBeNull' => false,
	// Minimum value (int)
	'minValue' => false,
	// Maximum value (int)
	'maxValue' => false,
	// Minimum length (string)
	'minLength' => false,
	// Maximum length (string)
	'maxLength' => false,
	// Any one value from the Array
	'enumValues' => false,
	// Values belonging to this Array
	'setValues' => false,

	// Values should pass this regex before use
	'regex' => false
];

Custom DataTypes Example

  • $PrimaryKey
public static $PrimaryKey = [
	// PHP data type (bool, int, float, string)
	'dataType' => 'int',
	// Minimum value (int)
	'minValue' => 1
];

- $Varchar50

public static $Varchar50 = [
	// PHP data type (bool, int, float, string)
	'dataType' => 'string',
	// Minimum length (string)
	'minLength' => 0,
	// Maximum length (string)
	'maxLength' => 50
];

Usage

When these data types are configured for a param in route or SQL config payload; there is a validation performed on the received data to fit the configured criteria of respective data type.

Contributing

Issues and feature request are welcome.<br /> Feel free to share them on issues page

Author

  • Ramesh N. Jangid (Sharma)

Github: @polygoncoin

License

Copyright © 2026 Ramesh N. Jangid (Sharma).<br /> This project is MIT licensed.