验证: “{{param}}”必须是数值
一般用于大数处理（超过double表示范围的数,一般会用字符串来表示）
如果是正常范围内的数, 可以使用'Int'或'Float'来检测
@param $value mixed 参数值
@param $reason string|null 验证失败的错误提示字符串. 如果为null, 则自动生成
@param $alias string 参数别名, 用于错误提示
@return mixed
@throws ValidationException
775749
public static function validateNumeric($value, $reason = null, $alias = 'Parameter')
    {
        if (is_string($value)) {
            if (preg_match('/^\-?[0-9.]+$/', $value) === 1) {
                $count = 0; //小数点的个数
                $i = 0;
                while (($i = strpos($value, '.', $i)) !== false) {
                    $count++;
                    $i += 1;
                }
                if ($count === 0)
                    return $value;
                else if ($count === 1) {
                    if ($value !== '.' && $value !== '-.')
                        return $value;
                }
            }
            $isTypeError = false;
        } else
            $isTypeError = true;

        if ($reason !== null)
            throw new ValidationException($reason);

        if ($isTypeError) {
            $error = self::getErrorTemplate('Str');
            $error = str_replace('{{param}}', $alias, $error);
        } else {
            $error = self::getErrorTemplate('Numeric');
            $error = str_replace('{{param}}', $alias, $error);
        }
        throw new ValidationException($error);
    }
25774
protected function _validate_secint($value, $parameters)
    {
        $v = $this->secint->decode($value, isset($parameters[0]) ? $parameters[0] : '');
        if ($v === false) {
            return null;
        } else {
            return $v;
        }
    }
928126
protected function _validate_range($value, $parameters)
    {
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $value = $this->_validate_float($value);

        return $value === null || $value < $parameters[0] || $value > $parameters[1] ? null : $value;
    }
380431
private function findAliasedValue(string $column, $value) {
		$alias = null;
		foreach ($this->alias_data as $k => $v) {
			// todo: maybe need column prefix with alias
			if (strpos($column, $k) !== false) {
				$alias = $k;
				break;
			}
		}
		if (!empty($alias)) {
			return $this->alias_object->getIdByCode($alias, str_replace('::id::', '', $value), true, ['skip_acl' => true]);
		} else {
			return false;
		}
	}
485936
public function validate($value, Constraint $constraint)
    {
        $mainAliases = $value->getAliases()->filter(function(SiteAliasInterface $alias) {
            return $alias->isMain();
        });
        if ($mainAliases->count() > 1) {
            foreach ($mainAliases as $name => $siteAlias) {
                $this->context->buildViolation($constraint->message)
                    ->atPath('aliases[' . $name . '].main')
                    ->addViolation();
            }
        }
    }
733904
protected function _validate_max($value, $parameters)
    {
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $value = $this->_validate_float($value);

        return $value === null || $value > $parameters[0] ? null : $value;
    }
1058386
public static function getCharacterSetEciByValue(int $value) : ?self
    {
        if ($value < 0 || $value >= 900) {
            throw new InvalidArgumentException('Value must be between 0 and 900');
        }

        $valueToEci = self::valueToEci();

        if (! array_key_exists($value, $valueToEci)) {
            return null;
        }

        return $valueToEci[$value];
    }
1276189
public function validateValueType($value)
    {
        if ($this->hasOption(Entity\Reflection\Property\Option\Primary::KEY)
            && (Entity\Reflection\Property\Option\Primary::isEmpty($value))
        ) {
            throw new Exception\InvalidArgumentException(
                "Primary value can not be empty string or null!",
                $value
            );
        }

        if ($value === null) {
            return;
        }

        // Enumeration
        if ($this->hasOption(Entity\Reflection\Property\Option\Enum::KEY)
            && !$this->getOption(Entity\Reflection\Property\Option\Enum::KEY)->isValid($value)
        ) {
            throw new Exception\InvalidArgumentException(
                "Value " . $value . " is not from defined entity enumeration "
                . "range on property " . $this->name . "!",
                $value
            );
        }

        // Scalar or array type
        if (self::isScalarType($this->type) || $this->type === self::TYPE_ARRAY) {

            if (gettype($value) === $this->type) {
                return;
            }
            throw new Exception\InvalidArgumentException(
                "Expected " . $this->type . " but " . gettype($value)
                . " given on property " . $this->name . "!",
                $value
            );
        }

        // Object validation
        $givenType = gettype($value);
        if ($givenType === "object") {
            $givenType = get_class($value);
        }

        if ($this->type === self::TYPE_ENTITY) {
            // Entity

            $expectedEntityClass = Convention::nameToClass($this->typeOption, Convention::ENTITY_MASK);
            if ($value instanceof $expectedEntityClass) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected entity " . $this->typeOption . " but " . $givenType
                    . " given on property " . $this->name . "!",
                    $value
                );
            }
        } elseif ($this->type === self::TYPE_COLLECTION) {
            // Collection

            $entityClass = Convention::nameToClass($this->typeOption, Convention::ENTITY_MASK);
            if (!$value instanceof Entity\Collection) {

                throw new Exception\InvalidArgumentException(
                    "Expected entity collection but " . $givenType . " given on"
                    . " property " . $this->name . "!",
                    $value
                );
            } elseif ($value->getEntityClass() !== $entityClass) {
                throw new Exception\InvalidArgumentException(
                    "Expected collection of entity " . $entityClass
                    . " but collection of entity " . $value->getEntityClass()
                    . " given on property " . $this->name . "!",
                    $value
                );
            } else {
                return;
            }
        } elseif ($this->type === self::TYPE_DATETIME) {
            // DateTime

            if ($value instanceof \DateTime) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected DateTime but " . $givenType . " given on"
                    . " property " . $this->name . "!",
                    $value
                );
            }
        } elseif ($this->type === self::TYPE_DATE) {
            // Date

            if ($value instanceof \DateTime) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected date as DateTime object but " . $givenType
                    . " given on property " . $this->name . "!",
                    $value
                );
            }
        } else {
            // Unexpected

            throw new \Exception("Unsupported type " . $this->type . "!");
        }
    }
553141
protected function _validate_const($value, $parameter = null)
    {
        $context = $this->_context;

        $model = $context->model;
        $constants = $model::consts($parameter ?: $context->field);
        if (isset($constants[$value])) {
            return $value;
        } else {
            return ($r = array_search($value, $constants, true)) !== false ? $r : null;
        }
    }
461637
public function setAlias(string $alias, string $value)
    {
        if (0 !== \strpos($alias, '@')) {
            throw new AliasException('Alias should starts with @');
        }
        $this->aliases[$alias] = $value;
    }
521979
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (null === $value) {
            return [];
        }

        if (!is_array($value)) {
            return [new Error(
                $path,
                'constraint.coordinatearray.invalidtype',
                ['type' => is_object($value) ? get_class($value) : gettype($value)]
            )];
        }

        if (!isset($value['lat']) || !isset($value['lon'])) {
            return [new Error($path, 'constraint.coordinatearray.invalidformat', ['value' => json_encode($value)])];
        }

        $lat = $value['lat'];
        $lon = $value['lon'];

        if ($lat < -90 || $lat > 90 || $lon < -180 || $lon > 180) {
            return [new Error($path, 'constraint.coordinatearray.invalidvalue', ['value' => json_encode($value)])];
        }

        return [];
    }
984543
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
        $groups = $this->client->registry->findGroups($value);
        if(\count($groups) === 1) {
            return true;
        }
        
        if(\count($groups) === 0) {
            return false;
        }
        
        return \CharlotteDunois\Livia\Utils\DataHelpers::disambiguation($groups, 'groups', 'name').\PHP_EOL;
    }
347903
public function cas($condition, $value = null) {
		if (!is_null($value)) {
			$this->_switchValue = $value;
		}
		if ((is_null($this->_switchCondition) && true === $condition) ||
			(!is_null($this->_switchCondition) && $this->_switchCondition == $condition)) {
			return $this->_switchValue;
		}
		return null;
	}
171456
protected function _validate_ext($value, $parameter)
    {
        if ($value === '') {
            return '';
        }

        $ext = pathinfo($value, PATHINFO_EXTENSION);
        return in_array(strtolower($ext), preg_split('#[\s,]+#', $parameter, -1, PREG_SPLIT_NO_EMPTY), true) ? $value : null;
    }
1149223
protected function getParamValue($param, $paramOptions, $value)
    {
        if (! empty($paramOptions['arguments'])) {
            $ret = array();
            foreach ($paramOptions['arguments'] as $arg => $opts) {
                $p = $arg;
                if (! empty($opts['alias'])) {
                    $alias = implode('|', (array) $opts['alias']);
                    $p .= "|\\b{$alias}";
                }
                $regex = "(\\b{$p})\\[(.*?)\\]";
                if (preg_match("%{$regex}%", $value, $match)) {
                    $ret[$arg] = $this->getParamValue($arg, $opts, $match[2]);
                }
            }

            return $ret;
        } else {
            // Using RegEx?
            if (! empty($paramOptions['regex'])) {
                if (! preg_match("%^(?:{$paramOptions['regex']})$%", $value)) {
                    throw new ErrorException("'{$value}' is not a valid value for: {$param}");
                }
            }

            $cast = ! empty($paramOptions['cast']) ? $paramOptions['cast'] : 'string';

            return $this->castValue($cast, $value);
        }
    }
808939
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
        $value = \mb_strtolower($value);
        return (\in_array($value, $this->truthy) || \in_array($value, $this->falsey));
    }
1315430
function validate($value, $options = null)
    {
        if (isset($this->_data[$this->name])) {
            $callback = $this->_data[$this->name];
            if (isset($callback[1])) {
                return call_user_func(array($callback[1], $callback[0]), $value, $options);
            } elseif ($this->_BCMode[$this->name]) {
                return $callback[0]('', $value, $options);
            } else {
                return $callback[0]($value, $options);
            }
        } elseif (is_callable($options)) {
            return call_user_func($options, $value);
        } else {
            return true;
        }
    }