Validates the name and creates variations
544235
def vary_name(name: Text):
    

    snake = re.match(r'^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$', name)

    if not snake:
        fail('The project name is not a valid snake-case Python variable name')

    camel = [x[0].upper() + x[1:] for x in name.split('_')]

    return {
        'project_name_snake': name,
        'project_name_camel': ''.join(camel),
        'project_name_readable': ' '.join(camel),
    }
1012284
def __set_name(self, value):
        '''
        
        '''
        if not value or not len(value):
            raise ValueError("Invalid name.")

        self.__name = value
601686
def _name_matches(name, matches):
    '''
    
    '''
    for m in matches:
        if name.endswith(m):
            return True
        if name.lower().endswith('_' + m.lower()):
            return True
        if name.lower() == m.lower():
            return True
    return False
373342
function generateNamedFieldExtractors(input) {
  var names = input.filter(function(matcher, index, array) {
    // has a name?
    return matcher.name;
  });
  // has duplicates?
  names.forEach(function(matcher, index, array) {
    var isDuplicate = array.slice(0, index).some(function(previousMatcher) {
      return previousMatcher.name == matcher.name;
    });
    if (isDuplicate) {
      throw new Error("duplicate named field '" + matcher.name + "'");
    }
  });
  return names;
}
1328916
def _makeUniqueFilename(taken_names, name):
    
    if name in taken_names:
        # try to form up new name
        basename, ext = os.path.splitext(name)
        num = 1
        name = "%s-%d%s" % (basename, num, ext)
        while name in taken_names:
            num += 1
            name = "%s-%d%s" % (basename, num, ext)
    # finally, enter name into set
    taken_names.add(name)
    return name
1077061
def validate_name(ctx, param, value):
    """"""
    if not value:
        value = os.path.basename(ctx.params['directory'].rstrip(os.path.sep))
    return value
1033170
def valid(self, name):
    
    name = re.sub('[^0-9a-zA-Z_]', '', name)
    if re.match('[0-9]', name):
      name = '_' + name
    return name
1043384
protected function validateNameCreate()
    {
        $name = $this->getSubmitted('name');

        if (strlen($name) == 0) {
            $this->setErrorRequired('name', $this->translation->text('Name'));
            return false;
        }

        $pathinfo = pathinfo($name);

        if (!empty($pathinfo['extension'])) {
            // Validate filename. Allow only alphanumeric chars, underscores, dashes and dots
            $name = trim($pathinfo['dirname'], '.');
            if (preg_match('/^[\w-.]+$/', $pathinfo['basename']) !== 1) {
                $this->setErrorInvalid('name', $this->translation->text('Name'));
                return false;
            }
        }

        // Validate directory path
        if ($name && preg_match('/^[\w-]+[\w-\/]*[\w-]+$|^[\w-]$/', $name) !== 1) {
            $this->setErrorInvalid('name', $this->translation->text('Name'));
            return false;
        }

        return true;
    }
766891
function(attrName) {
    return function(err, validationErrMsg) {
      ranCount++
      if (returned) return

      // If error, return, and set `returned` to true.
      if (err) {
        returned = true
        return done(err)
      }

      // Add the validation error to the object `validationErrors`
      if (validationErrMsg) {
        self._merge(validationErrors, validationErrMsg, (prefix || '') + '.' + attrName)
        isValid = false
      }

      if (ranCount === attrNames.length) _runAfter()
    }
  }
116512
function validateString(context, name, def, map) {
  var value = context[name]

  if (value == null) {
    value = def
  }

  value = String(value)

  if (!(value in map)) {
    raise(value, 'options.' + name)
  }

  context[name] = value
}
10444
private void validateName(String name) throws DDFException {
    Boolean isNameExisted;
    try {
      this.getManager().getDDFByName(name);
      isNameExisted = true;
    } catch (DDFException e) {
      isNameExisted = false;
    }
    if(isNameExisted) {
      throw new DDFException(String.format("DDF with name %s already exists", name));
    }

    Pattern p = Pattern.compile("^[a-zA-Z0-9_-]*$");
    Matcher m = p.matcher(name);
    if(!m.find()) {
      throw new DDFException(String.format("Invalid name %s, only allow alphanumeric (uppercase and lowercase a-z, " +
          "numbers 0-9) and dash (\"-\") and underscore (\"_\")", name));
    }
  }
1263892
def validate(self, *args):
        
        super(self.__class__, self).validate(*args)
        if not self.name:
            raise ValidationError('name is required for Data')
570600
protected function formatName()
    {
        $name = str_replace('\\', '/', trim($this->options['name']));
        
        if (strpos($name, '/')) {
            $names = explode('/', $name);
            $name = array_pop($names);
            if (!$name) {
                $name = array_pop($names);
            }
        }
        
        $this->options['name'] = StringHelper::toUnderscoreVariable($name);
    }
130790
function createRuleWithVariation(rule, variationName) {
  const selector = getSelectorName(rule, variationName);
  return postcss.rule({
    selector,
  });
}
469806
function makeValidation(name, exp, parser) {
    return function (input) {
        if (typeof input !== 'string') {
            throw new TypeError('Cannot validate ' + name + '. Input must be a string.');
        }
        var validate = function () {
            return input.match(exp) ? true : false;
        };
        return {
            valid: validate(),
            parse: function () {
                if (!validate()) {
                    return false;
                }
                var captures = exp.exec(input);
                return parser(captures);
            }
        };
    };
}
58788
def _generate_unique_name(seed, existing_names):
        '''
        
        '''
        if seed == '':
            raise ValueError('Name seed must be an non-empty string')

        # Make the seed meet C-style naming convention
        seed = re.sub('[^0-9a-zA-Z]', '_', seed)  # Only alphabets and numbers are allowed
        if re.match('^[0-9]', seed):  # The first symbol cannot be a number
            seed = '_' + seed

        # If seed has never been seen, we return it as it is. Otherwise, we will append an number to make it unique.
        if seed not in existing_names:
            existing_names.add(seed)
            return seed
        else:
            i = 1
            while seed + str(i) in existing_names:
                i += 1
            new_name = seed + str(i)
            existing_names.add(new_name)
            return new_name
1153104
function validateDuplicateName(cb) {
    var formId = formData._id;
    var formName = formData.name;

    if (!formName) {
      return cb(new Error("No form name passed"));
    }

    var query = {};

    //If there is a form id, then the query to the form model must exclude the current form id that is being updated.
    if (formId) {
      query.name = formName;
      //Excluding the formId that is being updated.
      query["_id"] = {"$nin": [formId]};
    } else { //Just checking that the form name exists as a form is being created
      query.name = formName;
    }

    formModel.count(query, function(err, count) {
      if (err) {
        return cb(err);
      }

      //If the number of found forms is > 0, then there is another form with the same name. Do not save the form.
      if (count > 0) {
        return cb(new Error("Form with name " + formName + " already exists found."));
      } else {//No duplicates, can proceed with saving the form.
        return cb();
      }
    });
  }