/**
* {@inheritDoc}
*/
protected function _validationRules()
{
return [
'name' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
NotEmpty::class,
[
StringLength::class,
['max' => 255],
],
[
NoRecordExists::class,
[
'table' => OptionTableMap::getTableMap()->getName(),
'field' => OptionTableMap::getTableMap()->getColumn('name')->getName(),
'exclude' => [
$this->getData('thingId')
],
],
]
],
'slug' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
NotEmpty::class,
[
StringLength::class,
['max' => 255],
],
],
'thingId' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
NotEmpty::class,
[
StringLength::class,
['max' => 11],
],
[
Regex::class,
['pattern' => '/^[1-9]\d*$/'],
],
[
RecordExists::class,
[
'table' => ThingTableMap::getTableMap()->getName(),
'field' => ThingTableMap::getTableMap()->getColumn('id')->getName(),
]
],
],
'select' => [
[
Regex::class,
['pattern' => '/^[01]*$/'],
],
],
'accounting' => [
[
Regex::class,
['pattern' => '/^[01]*$/'],
],
],
];
}
/**
* {@inheritDoc}
*/
protected function _validationRules()
{
$qntValidSelect = new Zend_Db_Select(Zend_Db_Table_Abstract::getDefaultAdapter());
$qntValidSelect
->from(OptionTableMap::TABLE_NAME)
->where('Name = ?', $this->getData('name'))
->where('ThingId = ?', $this->getData('thingId'));
return [
'name' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 255],
],
],
'slug' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 255],
],
],
'thingId' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 11],
],
[
'Regex',
['pattern' => '/^[1-9]\d*$/'],
],
[
'DB_RecordExists',
[
'table' => ThingTableMap::getTableMap()->getName(),
'field' => ThingTableMap::getTableMap()->getColumn('id')->getName(),
]
],
],
'select' => [
[
'Regex',
['pattern' => '/^[01]*$/'],
],
],
'accounting' => [
[
'Regex',
['pattern' => '/^[01]*$/'],
],
],
];
}