$constraint =
new PrimitiveTypeConstraint();
$validate =
new PrimitiveTypeConstraintValidator();
$validate->
initialize($context);
$validate->
validate($value,
$constraint);
} public function provideTestValidate() { $data =
[];
$data[] =
[new BooleanData(DataDefinition::
create('boolean'
)), NULL, TRUE
];
$data[] =
[new BooleanData(DataDefinition::
create('boolean'
)), 1, TRUE
];
$data[] =
[new BooleanData(DataDefinition::
create('boolean'
)), 'test', FALSE
];
$data[] =
[new FloatData(DataDefinition::
create('float'
)), 1.5, TRUE
];
$data[] =
[new FloatData(DataDefinition::
create('float'
)), 'test', FALSE
];
$data[] =
[new IntegerData(DataDefinition::
create('integer'
)), 1, TRUE
];
$data[] =
[new IntegerData(DataDefinition::
create('integer'
)), 1.5, FALSE
];
$data[] =
[new IntegerData(DataDefinition::
create('integer'
)), 'test', FALSE
];
$data[] =
[new StringData(DataDefinition::
create('string'
)), 'test', TRUE
];
$data[] =
[new StringData(DataDefinition::
create('string'
)),
new TranslatableMarkup('test'
), TRUE
];
// It is odd that 1 is a valid string.