Validates given slug depending on settings.
540151
def is_valid_article_slug(article, language, slug):
    
    from ..models import Title

    qs = Title.objects.filter(slug=slug, language=language)

    if article.pk:
        qs = qs.exclude(Q(language=language) & Q(article=article))
        qs = qs.exclude(article__publisher_public=article)

    if qs.count():
        return False

    return True
763262
def is_slug_available(self, slug, **kwargs):
        
        try:
            self.get(slug=slug, **kwargs)
            return False
        except self.model.DoesNotExist:
            return True
596116
def validate(self):
        """"""
        required_fields = ('slug', 'name', 'process_type', 'version')
        for field in required_fields:
            if getattr(self.metadata, field, None) is None:
                raise ValidationError("process '{}' is missing required meta attribute: {}".format(
                    self.metadata.slug or '<unknown>', field))

        if not PROCESSOR_TYPE_RE.match(self.metadata.process_type):
            raise ValidationError("process '{}' has invalid type: {}".format(
                self.metadata.slug, self.metadata.process_type))
165444
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, str):
            raise ValidationError("field must be a string")

        super().validate(value)
68367
def validate(self):
        """"""
        try:
            for pkg in self.resolved_packages:
                pkg.validate_data()
        except RezError as e:
            raise ResolvedContextError("%s: %s" % (e.__class__.__name__, str(e)))
1084636
def _validate_required_settings(
		self, application_id, application_config, required_settings
	):
		""""""

		for setting_key in required_settings:
			if setting_key not in application_config.keys():
				raise ImproperlyConfigured(
					MISSING_SETTING.format(
						application_id=application_id, setting=setting_key
					)
				)
1251273
def validate(self):
        """"""
        for context_name in self.context_names:
            context = self.context(context_name)
            try:
                context.validate()
            except ResolvedContextError as e:
                raise SuiteError("Error in context %r: %s"
                                 % (context_name, str(e)))
56438
public static function checkSlug($slugField, $slug, $id = null)
    {
        $instance   = new static;

        $slug   = $slug;
        $query = $instance->where($slugField, $slug);

        if($id != null)
        {
            $query->whereNotIn($instance->getKeyName(), [$id]);
        }

        $nObjects = $query->count();

        if($nObjects > 0)
        {
            $suffix = 0;
            while($nObjects > 0)
            {
                $suffix++;
                $slug       = $slug . '-' . $suffix;
                $nObjects   = $instance->where($slugField, $slug)->count();
            }
        }

        return $slug;
    }
367189
def _check_endings(self):
        """"""
        if self.slug.startswith("/") and self.slug.endswith("/"):
            raise InvalidSlugError(
                _("Invalid slug. Did you mean {}, without the leading and trailing slashes?".format(self.slug.strip("/"))))
        elif self.slug.startswith("/"):
            raise InvalidSlugError(
                _("Invalid slug. Did you mean {}, without the leading slash?".format(self.slug.strip("/"))))
        elif self.slug.endswith("/"):
            raise InvalidSlugError(
                _("Invalid slug. Did you mean {}, without the trailing slash?".format(self.slug.strip("/"))))
163899
def matches(property_name, regex, *, present_optional=False, message=None):
    """"""
    def check(val):
      """Checks that a value matches a scope-enclosed regex."""
      if not val:
        return present_optional
      else:
        return True if regex.search(val) else False

    return Validation(check, property_name, message)
523427
function validateUrl (url) {
  if (!url) {
    return option.some('Url is not specified')
  }
  if (typeof url !== 'string') {
    return option.some('Url should be type of string')
  }
  return option.none
}
66642
def automatic_slug_renaming(slug, is_slug_safe):
    """"""

    if not isinstance(is_slug_safe, collections.Callable):
        raise TypeError('is_slug_safe must be callable')

    if is_slug_safe(slug):
       return slug

    count = 2
    new_slug = slug + "-" + str(count)
    while not is_slug_safe(new_slug):
        count = count + 1
        new_slug = slug + "-" + str(count)
    return new_slug
1345602
def validate(self, name, value):
        """"""

        if self.valid_set and value not in self.valid_set:
            raise ImproperlyConfigured(
                "%s: \"%s\" is not a valid setting (choose between %s)." %
                (name, value, ", ".join("\"%s\"" % x for x in self.valid_set)))

        return value
1062335
protected function validateSlug($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if (!Validate::isSlug($value)) {
            return Message::getMessage(Message::SLUG, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        return null;
    }
648003
function validate(config, source) {

  if (typeof config.rules === 'object') {
    Object.keys(config.rules).forEach(function(id) {
      validateRuleOptions(id, config.rules[id], source);
    });
  }
}
836185
def RunValidationFromOptions(feed, options):
  """"""
  if options.performance:
    return ProfileRunValidationOutputFromOptions(feed, options)
  else:
    return RunValidationOutputFromOptions(feed, options)
1039232
def show_slug_with_level(context, page, lang=None, fallback=True):
    """"""
    if not lang:
        lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE)

    page = get_page_from_string_or_id(page, lang)
    if not page:
        return ''

    return {'content': page.slug_with_level(lang)}