Return errors for entity and translations.
@param  string[] $locales
@param  array    $groups validation groups
@return \Asgard\Validation\Report
518327
public function errorsI18N(array $locales=[], $groups=[]) {
		if(!$locales)
			$locales = $this->getLocales();
		$data = $this->toArrayRawI18N($locales);
		$validator = $this->getValidator($locales);

		return $validator->errors($data, $groups);
	}
1008757
public function getApiObjects($entities, $locale)
    {
        return array_map(
            function($entity) use ($locale) {
                return $this->getApiObject($entity, $locale);
            },
            $entities
        );
    }
1363825
public static function validate($object, $groups = null)
    {
        static::initialize();
        $errors = static::$validator->validate($object, null, $groups);
        if ($errors->count() != 0) {
            //Throw new exception containing the errors
            throw new ValidationFailedException($errors, $object);
        }
    }
323560
protected function checkGroups(array $groups)
    {
        $checkedGroups = array();
        foreach ($groups as $group) {
            if (true === is_string($group) && false === in_array($group, $checkedGroups)) {
                $checkedGroups[] = (string)$group;
            }
        }
        return $checkedGroups;
    }
1019980
protected function renderTranslatedFields(array $locales, $value, $originalValue, array $errors)
    {
        // Render the inputs for all relevant locales
        $rendered = [];

        foreach ($locales as $locale) {

            $rendered[ $locale ] = $this->renderField(
                $this->getValueForLocale($locale, $value),
                $this->getValueForLocale($locale, $originalValue),
                $this->getErrorsForLocale($locale, $errors),
                $locale
            );
        }

        return view(static::FORM_FIELD_TRANSLATED_VIEW, [
            'field'          => $this->field,
            'locales'        => $locales,
            'value'          => $value,
            'errors'         => $errors,
            'localeRendered' => $rendered,
        ]);
    }
907614
public static function findByName($tags, string $group = null, string $locale = null): Collection
    {
        $locale = $locale ?? app()->getLocale();

        return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) {
            return ($exists = static::firstByName($tag, $group, $locale)) ? $exists->getKey() : null;
        })->filter()->unique();
    }
738248
public function withErrors(array $errors = []): CollectionElement
    {
        $this->allErrors = $errors;

        array_walk(
            $this->elements,
            function (ElementInterface $element) use ($errors) {
                $name = $element->name();
                if (isset($errors[$name]) && $element instanceof ErrorAwareInterface) {
                    $element->withErrors($errors);
                    unset($errors[$name]);
                }
            }
        );

        // assign errors without matches to the collection itself.
        $this->errors = $errors;

        return $this;
    }
1085748
public function getByKey($key, $locale, $group = null) {
        $query = $this->source
            ->select('languages.slug as locale', 'translations.*')
            ->join('languages', 'languages.id', '=','translations.language_id')
            ->where('languages.slug', $locale)
            ->whereKey($key);

        if($group)
            $query->where('group', $group);

        return $query
            ->first();
    }
1229933
public function getCreateErrors(array $data, array &$errors = [], $fieldset = null)
    {
        $schema = $this->schema;

        if ($fieldset) {
            $schema = $fieldset;
        }

        $fields = $schema->getFields();
        $table = $schema->getName();
        foreach ($fields as $field) {
            $name = $table . '_' . $field['name'];

            if ($field['field']['type'] === 'fieldset' && isset($data[$name])) {
                if (!isset($errors[$name])) {
                    $errors[$name] = [];
                }

                if (isset($field['field']['attributes']['data-multiple'])
                    && !$field['field']['attributes']['data-multiple']
                ) {
                    $errors[$name] = $this->getCreateErrors(
                        $data[$name],
                        $errors[$name],
                        Fieldset::i($field['field']['parameters'])
                    );

                    if (empty($errors[$name])) {
                        unset($errors[$name]);
                    }

                    continue;
                }

                foreach($data[$name] as $index => $row) {
                    if (!isset($errors[$name][$index])) {
                        $errors[$name][$index] = [];
                    }

                    $errors[$name][$index] = $this->getCreateErrors(
                        $row,
                        $errors[$name][$index],
                        Fieldset::i($field['field']['parameters'])
                    );

                    if (empty($errors[$name][$index])) {
                        unset($errors[$name][$index]);
                    }
                }

                if (empty($errors[$name])) {
                    unset($errors[$name]);
                }

                continue;
            }

            if (isset($field['validation'])) {
                foreach ($field['validation'] as $validation) {
                    if ($validation['method'] === 'required'
                        && (
                            !isset($data[$name])
                            || (
                                is_array($data[$name])
                                && empty($data[$name])
                            )
                            || (
                                !is_array($data[$name])
                                && !strlen('' . $data[$name])
                            )
                        )
                    ) {
                        $errors[$name] = $validation['message'];
                    }
                }
            }
        }

        // is this checker not fieldset specific?
        // if yes let's check relations
        if (!$fieldset) {
            $relations = $this->schema->getRelations();
            foreach ($relations as $relation) {
                if ($relation['many'] != 1) {
                    continue;
                }

                if (!isset($data[$relation['primary2']]) || !is_numeric($data[$relation['primary2']])) {
                    $errors[$relation['primary2']] = sprintf('%s should be valid', $relation['singular']);
                }
            }
        }

        return $this->getOptionalErrors($data, $errors, $fieldset);
    }
764065
public function count(array $locales = null,  array $filters = null)
    {
        $query = TransUnitQuery::create()
            ->select('Id')
            ->distinct()
        ;

        $this->addTransUnitFilters($query, $filters);
        $this->addTranslationFilter($query, $locales, $filters);

        return $query->count($this->getConnection());
    }
1078903
public function findAllByIdsAndLocale($locale, $ids = '')
    {
        $products = $this->productRepository->findByLocaleAndIds($locale, explode(',', $ids));

        if ($products) {
            array_walk(
                $products,
                function (&$product) use ($locale) {
                    $product = $this->productFactory->createApiEntity($product, $locale);
                }
            );
        }

        return $products;
    }
130185
public function allToArray($locale, $group, $namespace = null)
    {
        $args = func_get_args();
        $args[] = config('app.locale');

        return $this->executeCallback(static::class, __FUNCTION__, $args, function () use ($locale, $group) {
            $array = DB::table('translations')
                    ->select(DB::raw("JSON_UNQUOTE(JSON_EXTRACT(`translation`, '$.".$locale."')) AS translation"), 'key')
                    ->where('group', $group)
                    ->pluck('translation', 'key')
                    ->all();

            return $array;
        });
    }
779784
public function loadSource($locale, $namespace, $group)
    {
        return $this->model
            ->whereLocale($locale)
            ->whereNamespace($namespace)
            ->whereGroup($group)
            ->get()
            ->keyBy('item')
            ->map(function ($translation) {
                return $translation['text'];
            })
            ->toArray();
    }
750688
protected function getErrors($value, $constraints = null, $groups = null)
    {
        /** @var ValidatorInterface $validator */
        $validator = $this->getContainer()->get(Config::getServiceName());

        return $validator->validate($value, $constraints, $groups);
    }
1111365
public function isValid($translations)
    {
        $this->message = null;

        if (empty($translations['General']['Locale'])) {
            $this->message = self::ERRORSTATE_LOCALEREQUIRED;
            return false;
        }

        if (empty($translations['General']['TranslatorName'])) {
            $this->message = self::ERRORSTATE_TRANSLATORINFOREQUIRED;
            return false;
        }

        /** @var LanguageDataProvider $languageDataProvider */
        $languageDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\LanguageDataProvider');
        /** @var RegionDataProvider $regionDataProvider */
        $regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');

        $allLanguages = $languageDataProvider->getLanguageList();
        $allCountries = $regionDataProvider->getCountryList();

        if ('eo.UTF-8' === $translations['General']['Locale']) {
            return true;
        }

        if (!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $translations['General']['Locale'], $matches)) {
            $this->message = self::ERRORSTATE_LOCALEINVALID;
            return false;
        } else if (!array_key_exists($matches[1], $allLanguages)) {
            $this->message = self::ERRORSTATE_LOCALEINVALIDLANGUAGE;
            return false;
        } else if (!array_key_exists(strtolower($matches[2]), $allCountries)) {
            $this->message = self::ERRORSTATE_LOCALEINVALIDCOUNTRY;
            return false;
        }

        return true;
    }
1251288
public static function arrayToJSONI18N(array $entities, array $locales=[], $depth=0) {
		foreach($entities as $k=>$entity)
			$entities[$k] = $entity->toArrayI18N($locales, $depth);
		return json_encode($entities);
	}
828254
public function getErrors($key = null, $group = null)
    {
        return $this->validator->getErrors($key, $group);
    }