if ($element instanceof PrimitiveInterface
) { $success =
($type == 'integer' &&
$element instanceof IntegerInterface
) ||
// Allow integer values in a float field.
(($type == 'double' ||
$type == 'integer'
) &&
$element instanceof FloatInterface
) || ($type == 'boolean' &&
$element instanceof BooleanInterface
) || ($type == 'string' &&
$element instanceof StringInterface
) ||
// Null values are allowed for all primitive types.
($value === NULL
);
} // Array elements can also opt-in for allowing a NULL value.
elseif ($element instanceof ArrayElement &&
$element->
isNullable() &&
$value === NULL
) { $success = TRUE;
} $class =
get_class($element);
if (!
$success) { return [$error_key => "variable type is
$type but applied schema class is
$class"
];
} } else { $errors =
[];
if (!
$element instanceof TraversableTypedDataInterface
) { $errors[$error_key] = 'non-scalar value but not defined as an array (such as mapping or sequence)';
}