public function validateUnique($value, array $options, array $context = null)
{
if ($context === null) {
$context = $options;
}
$entity = new Entity($context['data'], ['useSetters' => false, 'markNew' => $context['newRecord'], 'source' => $this->registryAlias()]);
$fields = array_merge([$context['field']], isset($options['scope']) ? (array) $options['scope'] : []);
$values = $entity->extract($fields);
foreach ($values as $field) {
if ($field !== null && !is_scalar($field)) {
return false;
}
}
$rule = new IsUnique($fields, $options);
return $rule($entity, ['repository' => $this]);
}