src/Executor/Values.php
protected static function isValidValue(TypeInterface $type, $value)
    {
        if ($type instanceof NonNullModifier) {
            if (NULL === $value) {
                return FALSE;
            }

            return self::isValidValue($type->getWrappedType(), $value);
        }

        if ($value === NULL) {
            return TRUE;
        }

        if ($type instanceof ListModifier) {
            $itemType = $type->getWrappedType();
            if (is_array($value)) {
                foreach ($value as $item) {
                    if (!self::isValidValue($itemType, $item)) {
                        return FALSE;
                    }
                }

                return TRUE;
            } else {
                return self::isValidValue($itemType, $value);
            }
        }

        if ($type instanceof InputObjectType) {
            $fields = $type->getFields();
            foreach ($fields as $fieldName => $field) {
                if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) {
                    return FALSE;
                }
            }

            return TRUE;
        }

        if ($type instanceof ScalarType || $type instanceof EnumType) {
            return NULL !== $type->coerce($value);
        }

        return FALSE;
    }
protected static function isValidValue(TypeInterface $type, $value)
    {
        if ($type instanceof NonNullModifier) {
            if (NULL === $value) {
                return FALSE;
            }

            return self::isValidValue($type->getWrappedType(), $value);
        }

        if ($value === NULL) {
            return TRUE;
        }

        if ($type instanceof ListModifier) {
            $itemType = $type->getWrappedType();
            if (is_array($value)) {
                foreach ($value as $item) {
                    if (!self::isValidValue($itemType, $item)) {
                        return FALSE;
                    }
                }

                return TRUE;
            } else {
                return self::isValidValue($itemType, $value);
            }
        }

        if ($type instanceof InputObjectType) {
            $fields = $type->getFields();
            foreach ($fields as $fieldName => $field) {
                if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) {
                    return FALSE;
                }
            }

            return TRUE;
        }

        if ($type instanceof ScalarType || $type instanceof EnumType) {
            return NULL !== $type->coerce($value);
        }

        return FALSE;
    }
protected static function isValidValue ( TypeInterface $ type , $ value ) { if ( $ type instanceof NonNullModifier ) { if ( NULL === $ value ) { return FALSE ; } return self :: isValidValue ( $ type -> getWrappedType ( ) , $ value ) ; } if ( $ value === NULL ) { return TRUE ; } if ( $ type instanceof ListModifier ) { $ itemType = $ type -> getWrappedType ( ) ; if ( is_array ( $ value ) ) { foreach ( $ value as $ item ) { if ( ! self :: isValidValue ( $ itemType , $ item ) ) { return FALSE ; } } return TRUE ; } else { return self :: isValidValue ( $ itemType , $ value ) ; } } if ( $ type instanceof InputObjectType ) { $ fields = $ type -> getFields ( ) ; foreach ( $ fields as $ fieldName => $ field ) { if ( ! self :: isValidValue ( $ field -> getType ( ) , isset ( $ value [ $ fieldName ] ) ? $ value [ $ fieldName ] : NULL ) ) { return FALSE ; } } return TRUE ; } if ( $ type instanceof ScalarType || $ type instanceof EnumType ) { return NULL !== $ type -> coerce ( $ value ) ; } return FALSE ; }
Given a type and any value, return true if that value is valid.

@param TypeInterface $type
@param $value

@return bool
Given a type and any value return true if that value is valid .