承接 hypejunction/hypeprototypervalidators 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hypejunction/hypeprototypervalidators

最新稳定版本:4.2.2

Composer 安装命令:

composer require hypejunction/hypeprototypervalidators

包简介

hypePrototyper validation rules

README 文档

README

Predefined Validators

type

Asserts that user input is expected to be of a certain type.

  • string
  • alnum - allows only alphanumeric characters and whitespaces
  • alpha - allows only alpha characters and whitespaces
  • int - allow only integer values
  • numeric - allows numeric values
  • date - allows date/time strings and objects
  • url - allows only valid URLs
  • email - allows only valid email addresses
	$field = array(
		'type' => 'text',
		'validation_rules' => array(
			'type' => 'alnum',
		),
	);

min and max

Asserts that user input is between min and max values

	$field = array(
		'type' => 'text',
		'validation_rules' => array(
			'type' => 'int',
			'min' => 10,
			'max' => 20,
		),
	);

minlength and maxlength

Asserts that the length of user input is between min and max values

	$field = array(
		'type' => 'password',
		'validation_rules' => array(
			'type' => 'string',
			'minlength' => 6,
			'maxlength' => 25,
		),
	);

contains

Asserts that user input contains a predefined string

	$field = array(
		'type' => 'text',
		'validation_rules' => array(
			'type' => 'string',
			'contains' => 'hello world',
		),
	);

regex

Asserts that user input matches a regex pattern

	$field = array(
		'type' => 'time',
		'validation_rules' => array(
			'type' => 'string',
			'regex' => '^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$',
		),
	);

Custom Validators

You can define custom validation rules, using the following pattern:


// Callback for validating user input
elgg_register_plugin_hook_handler('validate:my_rule', 'prototyper', 'my_callback');

// Register the validation rule to make it available in hypePrototyperUI
hypePrototyper()->config->registerValidationRule('my_rule');

Client-Side Validation

Partial client-side validation is available through Parsley.js. Do enable validation, add data-parsley-validate to your form attributes.


echo elgg_view_form('my_prototyped_form', array(
	'enctype' => 'multipart/form-data',
	'data-parsley-validate' => true,
), $vars);

统计信息

  • 总下载量: 186
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-07-31