public function validate($value) { if (isset($value) && $value instanceof Moa\DomainObject\ArrayProperty) { $value = $value->get(); if (isset($value)) { $value = (array) $value; } } parent::validate($value); if (isset($value) && !is_array($value)) { $this->error('is not an array'); } if ($this->isRequired() && count($value) == 0) { $this->error('cannot be empty'); } $type = $this->options['type']; if (isset($value) && $type) { foreach ($value as $k => $item) { try { $type->validate($item); } catch (TypeException $e) { $this->error("element '{$k}' " . $e->getMessage()); } } } }
public function validate($value) { if (isset($value) && $value instanceof Moa\DomainObject\LazyProperty) { $value = $value->get(); } else { $value = null; } parent::validate($value); $type = $this->options['type']; if (isset($value) && $type && !$value instanceof $type) { $this->error('is not an instance of ' . $type); } if (isset($value) && !$value->saved()) { try { $value->validate(); } catch (Moa\DomainObject\ValidationException $e) { $this->error('failed validation with message "' . $e->getMessage() . '"'); } } }
public function offsetSet($index, $newval) { $array = $this->getArrayCopy(); $this->type->set($array, $index, $newval); return parent::offsetSet($index, $array[$index]); }