Valida valor a ser inserido na meta

@param Meta $m
@param $value
@return mixed
963437
public static function meta(Meta $m)
    {
        if ($m->getColumn() !== "id") {
            self::checkDefaultSet($m);
            if (!empty($m->getValue()) && !in_array($m->getKey(), ["extend", "extend_add", "list", "selecao", "checkbox_rel"])) {
                self::checkRegular($m);
                self::convertValues($m);
                self::checkType($m);
                self::checkSize($m);
                self::checkValidate($m);
                self::checkValues($m);
            }
        }
    }
790453
public function addMeta($key, $value)
    {
        $existing = $this->meta()
            ->where('key', $key)
            ->where('value', Helpers::maybeEncode($value))
            ->first();

        if ($existing) {
            return false;
        }

        $meta = $this->meta()->create([
            'key'   => $key,
            'value' => $value,
        ]);

        return $meta->isSaved() ? $meta : $meta->getErrors();
    }
186537
public function addMeta($metaName, $metaValue)
    {
        if (!is_scalar($metaName) || (!is_scalar($metaValue) && !is_array($metaValue))) {
            throw new \InvalidArgumentException(sprintf('Invalid meta name "%s" or value "%s". Please provide scalar meta name and scalar or array meta value.', gettype($metaName), gettype($metaValue)), __LINE__);
        }
        $metaValue = is_scalar($metaValue) ? ((is_numeric($metaValue) || is_bool($metaValue) ? $metaValue : trim($metaValue))) : $metaValue;
        if ((is_scalar($metaValue) && $metaValue !== '') || is_array($metaValue)) {
            if (!array_key_exists($metaName, $this->meta)) {
                $this->meta[$metaName] = $metaValue;
            } elseif (is_array($this->meta[$metaName]) && is_array($metaValue)) {
                $this->meta[$metaName] = array_merge($this->meta[$metaName], $metaValue);
            } elseif (is_array($this->meta[$metaName])) {
                array_push($this->meta[$metaName], $metaValue);
            } else {
                $this->meta[$metaName] = $metaValue;
            }
            ksort($this->meta);
        }
        return $this;
    }
1048240
public function setMeta($key, $value = null)
	{
		if(is_array($key))
		{
			$this->meta = array_merge($this->meta, $key);
			return $this;
		}

		$this->meta[$key] = $value;

		return $this;
	}
64494
private function getTargetIndex($value, array $meta)
    {
        if (is_object($value)) {
            return $this->getObjectId($value, $meta);
        }
        $node = $this->nodeFactory->newInstance($value, $meta);
        $this->addNode($node);

        return $this->nodeIndex;
    }
311289
private static function getValidatorStaticMeta(): ValidatorStaticMeta
    {
        if (null === self::$validatorStaticMeta) {
            self::$validatorStaticMeta = new ValidatorStaticMeta(self::getDoctrineStaticMeta());
        }

        return self::$validatorStaticMeta;
    }
1258358
public byte[] toBinary(Object value, Object meta, boolean insertMeta) {
		return toBinary(value, meta, insertMeta, (input) -> {
			return mapper.writeValueAsBytes(input);
		}
20734
private static function checkSize(Meta $m)
    {
        if ($m->getSize() && in_array($m->getType(), ["varchar", "char", "tinytext", "text", "mediumtext", "longtext", "tinyint", "smallint", "mediumint", "int", "bigint"])) {
            $length = strlen($m->getValue());
            if ($m->getType() === "varchar" && $length > $m->getSize()) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);
            } elseif ($m->getType() === "char" && $length > 1) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "tinytext" && ($length > 255 || $length > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "text" && ($length > 65535 || $length > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "mediumtext" && ($length > 16777215 || $length > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "longtext" && ($length > 4294967295 || $length > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("tamanho máximo de caracteres excedido. Max {$m->getSize()}");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "tinyint" && ($m->getValue() > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("numero excedeu seu limite. Max " . $m->getSize());
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "smallint" && ($m->getValue() > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("numero excedeu seu limite. Max " . $m->getSize());
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "mediumint" && ($m->getValue() > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("numero excedeu seu limite. Max " . $m->getSize());
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "int" && !in_array($m->getKey(), ["list", "selecao", "checkbox_rel"]) && ($m->getValue() > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("numero excedeu seu limite. Max " . $m->getSize());
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getType() === "bigint" && ($m->getValue() > $m->getSize())) {
                if ($m->getDefault() === false)
                    $m->setError("numero excedeu seu limite. Max " . $m->getSize());
                else
                    $m->setValue($m->getDefault(), !1);
            }
        }
    }
581789
public function deleteMeta($key, $value = null)
    {
        return $value
            ? $this->meta()->where('key', $key)->where('value', $value)->delete()
            : $this->meta()->where('key', $key)->delete();
    }
162781
public function add_meta( $meta_key, $meta_value ) {
		return add_metadata( $this->meta_type, $this->get_id(), $meta_key, $meta_value, true );
	}
1246779
public function set($name, $value) {
		\Asgard\Common\ArrayUtils::set($this->metas, $name, $value);
		return $this;
	}
1149749
public function meta(Unidade $unidade, $name, $value = null)
    {
        $repo = $this->storage->getRepository(UnidadeMeta::class);
        
        if ($value === null) {
            $metadata = $repo->get($unidade, $name);
        } else {
            $metadata = $repo->set($unidade, $name, $value);
        }
        
        return $metadata;
    }
948309
public function meta($name, $value = null) {
        if ($value !== null) {
            $this->currentSchema[Cli::META][$name] = $value;
            return $this;
        }
        if (!isset($this->currentSchema[Cli::META][$name])) {
            return null;
        }
        return $this->currentSchema[Cli::META][$name];
    }
1335288
public function meta(Atendimento $atendimento, $name, $value = null)
    {
        $repo = $this->storage->getRepository(AtendimentoMeta::class);
        
        if ($value === null) {
            $metadata = $repo->get($atendimento, $name);
        } else {
            $metadata = $repo->set($atendimento, $name, $value);
        }
        
        return $metadata;
    }
1154650
protected function handleMagicValue($value)
    {
        switch (gettype($value)) {
            case 'string':
                $value = (new MagicValue($value, $this->user))->get();
                break;

            case 'array':
                foreach ($value as $key => $val) {
                    $value[$key] = (new MagicValue($val, $this->user))->get();
                }
                break;
        }

        return $value;
    }
475955
protected function newClientDate($value, $meta)
    {
        $format = Utility::get($meta, "format");
        $type = Utility::get($meta, "type");
        if ($format == null) {
            switch ($type) {
            case "date":
                $format = "Y-m-d";
                $toFormat = "Y,(n-1),d";
                break;
            case "time":
                $format = "H:i:s";
                $toFormat = "0,0,0,H,i,s";
                break;
            case "datetime":
            default:
                $format = "Y-m-d H:i:s";
                $toFormat = "Y,(n-1),d,H,i,s";
                break;
            }
        }
        //The (n-1) above is because in Javascript, month start from 0 to 11
        $date = \DateTime::createFromFormat($format, $value);

        if ($date) {
            return "new Date(" . \DateTime::createFromFormat($format, $value)->format($toFormat) . ")";
        }
        return "null";
    }
202334
protected function validate($value)
    {
        $f = $this->function;

        return Match::on(Option::create((boolean)$f($value, $this->messenger), false))
            ->Monad_Option_Some(true)
            ->Monad_Option_None(
                function () {
                    $this->messenger->add($this->msg);
                    return false;
                }
            )
            ->value();
    }