Any value literal may be a valid representation of a Scalar, depending on
that scalar type.
7585
function isValidScalar(context: ValidationContext, node: ValueNode): void {
  // Report any error at the full type expected by the location.
  const locationType = context.getInputType();
  if (!locationType) {
    return;
  }

  const type = getNamedType(locationType);

  if (!isScalarType(type)) {
    context.reportError(
      new GraphQLError(
        badValueMessage(
          inspect(locationType),
          print(node),
          enumTypeSuggestion(type, node),
        ),
        node,
      ),
    );
    return;
  }

  // Scalars determine if a literal value is valid via parseLiteral() which
  // may throw or return an invalid value to indicate failure.
  try {
    const parseResult = type.parseLiteral(node, undefined /* variables */);
    if (isInvalid(parseResult)) {
      context.reportError(
        new GraphQLError(
          badValueMessage(inspect(locationType), print(node)),
          node,
        ),
      );
    }
  } catch (error) {
    // Ensure a reference to the original error is maintained.
    context.reportError(
      new GraphQLError(
        badValueMessage(inspect(locationType), print(node), error.message),
        node,
        undefined,
        undefined,
        undefined,
        error,
      ),
    );
  }
}
1011941
def _isvalid(self, datatype):
        ''''''
        if datatype in self.meta:
            return bool(Dap._meta_valid[datatype].match(self.meta[datatype]))
        else:
            return datatype in Dap._optional_meta
1141373
def coerce_value(type, value):
    # type: (Any, Any) -> Union[List, Dict, int, float, bool, str, None]
    """"""
    if isinstance(type, GraphQLNonNull):
        # Note: we're not checking that the result of coerceValue is
        # non-null.
        # We only call this function after calling isValidValue.
        return coerce_value(type.of_type, value)

    if value is None:
        return None

    if isinstance(type, GraphQLList):
        item_type = type.of_type
        if not isinstance(value, string_types) and isinstance(value, Iterable):
            return [coerce_value(item_type, item) for item in value]
        else:
            return [coerce_value(item_type, value)]

    if isinstance(type, GraphQLInputObjectType):
        fields = type.fields
        obj = {}
        for field_name, field in fields.items():
            if field_name not in value:
                if field.default_value is not None:
                    field_value = field.default_value
                    obj[field.out_name or field_name] = field_value
            else:
                field_value = coerce_value(field.type, value.get(field_name))
                obj[field.out_name or field_name] = field_value

        return type.create_container(obj)

    assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), "Must be input type"

    return type.parse_value(value)
1139545
private static TernaryValue tryStrictEqualityComparison(Node left, Node right) {
    // First, try to evaluate based on the general type.
    ValueType leftValueType = NodeUtil.getKnownValueType(left);
    ValueType rightValueType = NodeUtil.getKnownValueType(right);
    if (leftValueType != ValueType.UNDETERMINED && rightValueType != ValueType.UNDETERMINED) {
      // Strict equality can only be true for values of the same type.
      if (leftValueType != rightValueType) {
        return TernaryValue.FALSE;
      }
      switch (leftValueType) {
        case VOID:
        case NULL:
          return TernaryValue.TRUE;
        case NUMBER: {
          if (NodeUtil.isNaN(left)) {
            return TernaryValue.FALSE;
          }
          if (NodeUtil.isNaN(right)) {
            return TernaryValue.FALSE;
          }
          Double lv = NodeUtil.getNumberValue(left);
          Double rv = NodeUtil.getNumberValue(right);
          if (lv != null && rv != null) {
            return TernaryValue.forBoolean(lv.doubleValue() == rv.doubleValue());
          }
          break;
        }
        case STRING: {
          String lv = NodeUtil.getStringValue(left);
          String rv = NodeUtil.getStringValue(right);
          if (lv != null && rv != null) {
            // In JS, browsers parse \v differently. So do not consider strings
            // equal if one contains \v.
            if (lv.indexOf('\u000B') != -1 || rv.indexOf('\u000B') != -1) {
              return TernaryValue.UNKNOWN;
            } else {
              return lv.equals(rv) ? TernaryValue.TRUE : TernaryValue.FALSE;
            }
          } else if (left.isTypeOf() && right.isTypeOf()
              && left.getFirstChild().isName() && right.getFirstChild().isName()
              && left.getFirstChild().getString().equals(right.getFirstChild().getString())) {
            // Special case, typeof a == typeof a is always true.
            return TernaryValue.TRUE;
          }
          break;
        }
        case BOOLEAN: {
          TernaryValue lv = NodeUtil.getPureBooleanValue(left);
          TernaryValue rv = NodeUtil.getPureBooleanValue(right);
          return lv.and(rv).or(lv.not().and(rv.not()));
        }
        default: // Symbol and Object cannot be folded in the general case.
          return TernaryValue.UNKNOWN;
      }
    }

    // Then, try to evaluate based on the value of the node. There's only one special case:
    // Any strict equality comparison against NaN returns false.
    if (NodeUtil.isNaN(left) || NodeUtil.isNaN(right)) {
      return TernaryValue.FALSE;
    }
    return TernaryValue.UNKNOWN;
  }
746902
function isValue(val) {
    return (!isUndefined(val)
        && !isNull(val) && !(isNumber(val) && isNaN(val))
        && !isInfinite(val));
}
1281425
function _validateTypeValue(v) {
  // can be a string or an empty object
  if(_isString(v) || _isEmptyObject(v)) {
    return;
  }

  // must be an array
  var isValid = false;
  if(_isArray(v)) {
    // must contain only strings
    isValid = true;
    for(var i = 0; i < v.length; ++i) {
      if(!(_isString(v[i]))) {
        isValid = false;
        break;
      }
    }
  }

  if(!isValid) {
    throw new JsonLdError(
      'Invalid JSON-LD syntax; "@type" value must a string, an array of ' +
      'strings, or an empty object.', 'jsonld.SyntaxError', {value: v});
  }
}
597545
public function isValidConstantType()
    {
        if ($this->type === self::TYPE_AUTO) {
            $type = $this->determineType($this->value);
        } else {
            $type = $this->type;
        }

        // Valid types for constants.
        $scalarTypes = [
            self::TYPE_BOOLEAN,
            self::TYPE_NUMBER,
            self::TYPE_INTEGER,
            self::TYPE_FLOAT,
            self::TYPE_DOUBLE,
            self::TYPE_STRING,
            self::TYPE_CONSTANT,
            self::TYPE_NULL,
            self::TYPE_EXPRESSION
        ];

        return in_array($type, $scalarTypes);
    }
348854
function validateCompatibleTypes(startPos, endPos, x, y) {
  if (joinTypes(x.type(), y.type()) === null) {
    fail(startPos, endPos,
      'expected-values-to-have-compatible-types', [
        x.type(),
        y.type(),
      ]
    );
  }
}
454261
private AtomicValue parseIntegerLiteral() {

        String value = mToken.getContent();
        String type = "xs:integer";

        if (is(TokenType.VALUE, false)) {

            // is at least decimal literal (could also be a double literal)
            if (mToken.getType() == TokenType.POINT) {
                // TODO: not so nice, try to find a better solution
                final boolean isDouble = mScanner.lookUpTokens(2).getType() == TokenType.E_NUMBER;
                value = parseDecimalLiteral(value);
                type = isDouble ? "xs:double" : "xs:decimal";
            }

            // values containing an 'e' are double literals
            if (mToken.getType() == TokenType.E_NUMBER) {
                value = parseDoubleLiteral(value);
                type = "xs:double";
            }

        } else {
            // decimal literal that starts with a "."
            final boolean isDouble = mScanner.lookUpTokens(2).getType() == TokenType.E_NUMBER;
            value = parseDecimalLiteral("");
            type = isDouble ? "xs:double" : "xs:decimal";
        }

        is(TokenType.SPACE, true);

        final AtomicValue mIntLiteral =
            new AtomicValue(TypedValue.getBytes(value), NamePageHash.generateHashForString(type));
        return mIntLiteral;
    }
176786
def strict_logical(self, value):
        """"""
        if value is not None:
            if not isinstance(value, bool):
                raise TypeError(
                    'f90nml: error: strict_logical must be a logical value.')
            else:
                self._strict_logical = value
45990
function(val, defValue) {
		if (typeof defValue === "undefined") defValue = true;
		if (typeof val === "undefined") return defValue;
		if (val.toLowerCase() === "true" || val >= 1) return true;

		return false;
	}
970354
function isPrimitive (val) {
  if (val === null || val === undefined || val === Infinity || isLiterallyNaN(val)) {
    return true
  }
  return primitives.some(function (Class) {
    return val === Class || directInstanceOf(val, Class)
  })
}
844344
def _assert_is_type(name, value, value_type):
    """"""
    if not isinstance(value, value_type):
        if type(value_type) is tuple:
            types = ', '.join(t.__name__ for t in value_type)
            raise ValueError('{0} must be one of ({1})'.format(name, types))
        else:
            raise ValueError('{0} must be {1}'
                             .format(name, value_type.__name__))
182624
def p_scalar__literal(self, p):
        
        scalar_group = ''.join(p[2])
        p[0] = ScalarDispatch('%s\n' % dedent(scalar_group).replace('\n\n\n', '\n'), cast='str')
947560
def enforce_type(self, attr, val):
        """"""
        if not attr in self.types:
            return utfstr(val)
        elif self.types[attr] == 'int':
            return int(float(val))
        elif self.types[attr] == 'float':
            return float(val)
        else:
            return utfstr(val)
955734
def _valid_other_type(x, types):
    
    return all(any(isinstance(el, t) for t in types) for el in np.ravel(x))
133633
def validate(self, instance, value):
        """"""
        if not isinstance(value, (tuple, list, np.ndarray)):
            self.error(instance, value)
        if self.coerce:
            value = self.wrapper(value)
        valid_class = (
            self.wrapper if isinstance(self.wrapper, type) else np.ndarray
        )
        if not isinstance(value, valid_class):
            self.error(instance, value)
        allowed_kinds = ''.join(TYPE_MAPPINGS[typ] for typ in self.dtype)
        if value.dtype.kind not in allowed_kinds:
            self.error(instance, value, extra='Invalid dtype.')
        if self.shape is None:
            return value
        for shape in self.shape:
            if len(shape) != value.ndim:
                continue
            for i, shp in enumerate(shape):
                if shp not in ('*', value.shape[i]):
                    break
            else:
                return value
        self.error(instance, value, extra='Invalid shape.')