all fields are required by default unless otherwise stated
1433
def build_fields
      if @data.key?(:fields)
        @data[:fields].each do |k,v|
          v[:required] = true unless v.key?(:required)
        end
      else
        {city: {label:'City', required: true}, region: {label: 'Province', required: false}, postcode: {label: 'Post Code', required: false} }
      end
    end
674697
function ruleRequiredUnless($anotherfield, $value, $error_message = null) {
        return $this->_rule('required_unless:' . $anotherfield . ',' . $value, $error_message);
    }
255191
def _get_implicit_requirements(
        self,
        fields,
        requirements
    ):
        """"""
        for name, field in six.iteritems(fields):
            source = field.source
            # Requires may be manually set on the field -- if not,
            # assume the field requires only its source.
            requires = getattr(field, 'requires', None) or [source]
            for require in requires:
                if not require:
                    # ignore fields with empty source
                    continue

                requirement = require.split('.')
                if requirement[-1] == '':
                    # Change 'a.b.' -> 'a.b.*',
                    # supporting 'a.b.' for backwards compatibility.
                    requirement[-1] = '*'
                requirements.insert(requirement, TreeMap(), update=True)
502560
protected function setRequiredFields()
    {
        $requiredFields = [
            'transaction_id',
            'remote_ip',
            'amount',
            'currency',
            'return_success_url',
            'return_failure_url',
            'payment_method_category',
            'billing_country',
            'shipping_country'
        ];

        $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields);

        $requiredFieldValues = [
            'payment_method_category' => [
                self::PAYMENT_METHOD_CATEGORY_PAY_LATER,
                self::PAYMENT_METHOD_CATEGORY_PAY_OVER_TIME
            ],
            'billing_country'         => static::getAllowedCountries(),
            'shipping_country'        => static::getAllowedCountries()
        ];

        $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues);
    }
1267975
public function requireDefaultRecords()
	{
		parent::requireDefaultRecords();

		// Skip creation of default records
		if (!self::config()->create_default_pages) {
			return;
		}

		// Ensure that an assets path exists before we do any error page creation
		if (!file_exists(ASSETS_PATH)) {
			mkdir(ASSETS_PATH);
		}

		$code = self::$defaults['ErrorCode'];

        $page = UtilityPage::get()->filter('ErrorCode', $code)->first();
        $pageExists = !empty($page);
        if (!$pageExists) {

            $page = UtilityPage::get()->first();
		    $pageExists = ($page && $page->exists());

            //Only create a UtilityPage on dev/build if one does not already exist.

				$page = UtilityPage::create(array(
					'Title'      => _t('MaintenanceMode.TITLE', 'Undergoing Scheduled Maintenance'),
					'URLSegment' => _t('MaintenanceMode.URLSEGMENT', 'offline'),
					'MenuTitle'  => _t('MaintenanceMode.MENUTITLE', 'Utility Page'),
					'Content'    => _t('MaintenanceMode.CONTENT', '<h1>We&rsquo;ll be back soon!</h1>'
.'<p>Sorry for the inconvenience but '
.'our site is currently down for scheduled maintenance. '
.'If you need to you can always <a href="mailto:#">contact us</a>, '
.'otherwise we&rsquo;ll be back online shortly!</p>'
.'<p>&mdash; The Team</p>'),
					'ParentID'   => 0
				));
				$page->write();
                $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);

        }

        // Ensure a static error page is created from latest Utility Page content

        // Check if static files are enabled
        if (!self::config()->enable_static_file) {
            return;
        }

        // Ensure this page has cached error content
        $success = true;
        if (!$page->hasStaticPage()) {
            // Update static content
            $success = $page->writeStaticPage();
        } elseif ($pageExists) {
            // If page exists and already has content, no alteration_message is displayed
            return;
        }

        if ($success) {
            DB::alteration_message(
                sprintf('%s error Utility Page created', $code),
                'created'
            );
        } else {
            DB::alteration_message(
                sprintf('%s error Utility page could not be created. Please check permissions', $code),
                'error'
            );
        }

	}
583810
def validate_fields
      self.class.required_fields.each do |field|
        value = public_send(field)
        if value.nil? || value.respond_to?(:empty?) && value.empty?
          raise Outbox::MissingRequiredFieldError, "Missing required field: #{field}"
        end
      end
    end
1370436
def get_required(self, obj):
        """"""
        required = []

        for field_name, field in sorted(obj.fields.items()):
            if field.required:
                required.append(field.name)

        return required or missing
245468
function create_field( $field )
	{
		// load defaults
		// if field was loaded from db, these default will already be appield
		// if field was written by hand, it may be missing keys
		$field = apply_filters('acf/load_field_defaults', $field);
		
		
		// create field specific html
		do_action('acf/create_field/type=' . $field['type'], $field);
		
		
		// conditional logic
		if( $field['conditional_logic']['status'] )
		{
			$field['conditional_logic']['field'] = $field['key'];
			
			?>
<script type="text/javascript">
(function($) {
	
	if( typeof acf !== 'undefined' )
	{
		acf.conditional_logic.items.push(<?php echo json_encode($field['conditional_logic']); ?>);
	}
	
})(jQuery);	
</script>
			<?php
		}
		
	}
551789
def enforce_required_fields(self, attrs):
        
        missing = {
            field_name: self.missing_message
            for field_name in [self.field, self.date_field]
            if field_name not in attrs
        }
        if missing:
            raise ValidationError(missing)
1264566
def ValidateRequiredFieldsAreNotEmpty(gtfs_object, required_field_names,
                                      problems=None):
  
  no_missing_value = True
  for name in required_field_names:
    if IsEmpty(getattr(gtfs_object, name, None)):
      if problems:
        problems.MissingValue(name)
      no_missing_value = False
  return no_missing_value
1318628
def is_default(self):
        '''
        
        '''
        for field in self._fields:
            if not field.is_default():
                return False
        return super(Container, self).is_default()
513257
public function load_optional_fields() {
        global $DB;
        foreach ($this->optional_fields as $field=>$default) {
            if (property_exists($this, $field)) {
                continue;
            }
            if (empty($this->id)) {
                $this->$field = $default;
            } else {
                $this->$field = $DB->get_field($this->table, $field, array('id', $this->id));
            }
        }
    }
240600
public void setupFields()
    {
        FieldInfo field = null;
        field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field.setHidden(true);
        field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Date.class);
        field.setHidden(true);
        field = new FieldInfo(this, DELETED, 10, null, new Boolean(false));
        field.setDataClass(Boolean.class);
        field.setHidden(true);
        field = new FieldInfo(this, USER_GROUP_ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, USER_RESOURCE_ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, LOGIN_LEVEL, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field = new FieldInfo(this, ACCESS_LEVEL, Constants.DEFAULT_FIELD_LENGTH, null, null);
    }
26124
public function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(Site::get()->count() > 0) {
			return;
		}

		$site = Site::create();
		$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
		$site->IsDefault = true;
		$site->FolderID = Folder::find_or_make('default-site')->ID;
		$site->write();
		$site->publish('Stage', 'Live');

		DB::alteration_message('Default site created', 'created');

		$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
		$count = count($pages);
		if ($count > 0) {
			foreach($pages as $page) {
				$page->ParentID = $site->ID;
				$page->write();
				if ($page->isPublished()) {
					$page->publish('Stage', 'Live');
				}
			}

			DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
		}
	}
1043027
def setdefault(obj, field, default):
    """"""
    setattr(obj, field, getattr(obj, field, default))
387661
def all_default_fields():
    
    default_fields = []
    for item in dir(fields):
        if not item.startswith("__"):
            var = getattr(definitions, item)
            if isinstance(var, dict):
                if var.get('replace_null', False):
                    default_fields.append(var)
    return default_fields
1146133
def _required_attribute(element, name, default):
    
    if element.get(name) is None:
        element.set(name, default)