validates :sales_tax , length: {  }
 validates :product_type, length: {  }
 Nova instancia da classe Boleto
 @param [Hash] campos
 Montar o Hash de dados do pagamento no padrão utilizado pela Getnet
485298
def to_request
        order = {
          order_id:      self.order_id.to_s,
          sales_tax:     self.sales_tax.to_i,
          product_type:  self.product_type.to_s
        }

      return order
    end
1062763
protected function validateSubtractProduct()
    {
        $field = 'subtract';
        $value = $this->getSubmitted($field);

        if (isset($value)) {
            $this->setSubmitted($field, filter_var($value, FILTER_VALIDATE_BOOLEAN));
        }

        return true;
    }
196349
private void validateField(FieldDefinition fieldDef) {
        if (fieldDef.isScalarField()) {
            Utils.require(Utils.isEmpty(fieldDef.getAnalyzerName()),
                          "'analyzer' not allowed for OLAPMono application fields:" + fieldDef);
        } else if (fieldDef.isXLinkField()) {
            Utils.require(false, "XLinks are not allowed for OLAPMono applications: " + fieldDef);
        } else if (fieldDef.isLinkField()) {
            Utils.require(!fieldDef.isSharded(),
                          "Link fields cannot be sharded: {}", fieldDef);
        }
    }
776839
public function validate($params)
    {
        $params = $this->boolParams($params);

        if (!empty($params['html']) && (!empty($params['url']) || !empty($params['file'])))
            throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!");

        if (!empty($params['url']) && !empty($params['file']))
            throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!");

        if ((!empty($params['page_width']) && empty($params['page_height']))
            ||(empty($params['page_width']) && !empty($params['page_height'])))
        {
            throw new InvalidParameterException('Page width and page height must both be set or unset!');
        }
        if (!empty($params['filename']) && !is_string($params['filename']))
            throw new InvalidParameterException('Filename must be a string.');

        if (!empty($params['footer']) && !is_string($params['footer']))
            throw new InvalidParameterException('Footer must be a string.');

        if (!empty($params['header']) && !is_string($params['header']))
            throw new InvalidParameterException('Header must be a string.');

        if (!empty($params['header_spacing']) && !is_int($params['header_spacing']))
            throw new InvalidParameterException('Header spacing parameter must be an integer.');

        if (!empty($params['footer_spacing']) && !is_int($params['footer_spacing']))
            throw new InvalidParameterException('Footer spacing parameter must be an integer.');

        if (!empty($params['page_size']) && !is_string($params['page_size']))
            throw new InvalidParameterException('Page size must be a string of some standard page size.');

        if (!empty($params['dpi']) && (!is_int($params['dpi']) || $params['dpi']<75))
            throw new InvalidParameterException('DPI must be an integer larger than 75.');

        if (!empty($params['image_dpi']) && !is_int($params['image_dpi']))
            throw new InvalidParameterException('Image DPI must be an integer.');

        if (!empty($params['lowquality']) && (!is_int($params['lowquality']) || !in_array($params['lowquality'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Lowquality must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['orientation']) && (!is_string($params['orientation']) || !in_array($params['orientation'],
                array("landscape", "portrait"))))
            throw new InvalidParameterException('Orientation must be set to either "landscape" or "portrait"');

        if (!empty($params['margin_top']) && !is_int($params['margin_top']))
            throw new InvalidParameterException('Margin top must be an integer.');

        if (!empty($params['margin_bottom']) && !is_int($params['margin_bottom']))
            throw new InvalidParameterException('Margin top must be an integer.');

        if (!empty($params['margin_left']) && !is_int($params['margin_left']))
            throw new InvalidParameterException('Margin top must be an integer.');

        if (!empty($params['margin_right']) && !is_int($params['margin_right']))
            throw new InvalidParameterException('Margin top must be an integer.');

        if (!empty($params['background']) && (!is_int($params['background']) || !in_array($params['background'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Background must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['images']) && (!is_int($params['images']) || !in_array($params['images'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Images must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['page_width']) && !is_int($params['page_width']))
            throw new InvalidParameterException('Page width must be an integer.');

        if (!empty($params['page_height']) && !is_int($params['page_height']))
            throw new InvalidParameterException('Page height must be an integer.');

        if (!empty($params['disposition']) && (!is_string($params['disposition']) || !in_array($params['disposition'],
                    array("attachment", "inline"))))
            throw new InvalidParameterException('Disposition can only be "attachment or "inline"');

        if (!empty($params['group']) && !is_string($params['group']))
            throw new InvalidParameterException('Group must be a string.');

        if (!empty($params['engine_version']) && (!is_int($params['engine_version']) || !in_array($params['engine_version'],
        array( 11, 12 ) )))
            throw new InvalidParameterException(
                'Engine version can be integer 11 or 12');

        if (!empty($params['title']) && !is_string($params['title']))
            throw new InvalidParameterException('Title must be a string.');

        if (!empty($params['outline']) && (!is_int($params['outline']) || !in_array($params['outline'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Outline must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['outline_depth']) && !is_int($params['outline_depth']))
            throw new InvalidParameterException('Outline depth must be an integer.');

        if (!empty($params['encoding']) && !is_string($params['encoding']))
            throw new InvalidParameterException('Encoding must be a string.');

        if (!empty($params['javascript']) && (!is_int($params['javascript']) || !in_array($params['javascript'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Javascript must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['javascript_delay']) &&
            (!is_int($params['javascript_delay']) || $params['javascript_delay']<1 || $params['javascript_delay']>800))
            throw new InvalidParameterException('Javascript delay must be an integer larger than 1, but smaller than 800.');

        if (!empty($params['internal_links']) &&
            (!is_int($params['internal_links']) || !in_array($params['internal_links'], array( 0, 1 ) )))
            throw new InvalidParameterException(
                'Internal links must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['external_links']) &&
            (!is_int($params['external_links']) || !in_array($params['external_links'], array( 0, 1 ) )))
            throw new InvalidParameterException(
                'External links must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['page_offset']) && !is_int($params['page_offset']))
            throw new InvalidParameterException('Page offset must be an integer.');

        if (!empty($params['username']) && !is_string($params['username']))
            throw new InvalidParameterException('Username must be a string.');

        if (!empty($params['password']) && !is_string($params['password']))
            throw new InvalidParameterException('Password must be a string.');

        if (!empty($params['use_print_media']) &&
            (!is_int($params['use_print_media']) || !in_array($params['use_print_media'], array(
                    0, 1 ) )))
            throw new InvalidParameterException(
                'Use print media must be either 0 or 1 (alternative: use bool values');

        if (!empty($params['zoom']) && !is_numeric($params['zoom']))
            throw new InvalidParameterException('Zoom must be an integer.');

        if (!empty($params['viewport_size']) &&
            (!is_string($params['viewport_size'] || preg_match("^\\d+x\\d+$", $params['viewport_size']))))
            throw new InvalidParameterException('Viewport must be a string of a following format: [width]x[height].');

        if (!empty($params['id']) && !is_string($params['id']))
            throw new InvalidParameterException('ID must be a string.');

        /*if (!empty($params['file']))
            $this->validateFile($params['file']);*/

        return $params;
    }
35150
function BlockMeta(hash, height, time) {
  if (!(this instanceof BlockMeta))
    return new BlockMeta(hash, height, time);

  this.hash = hash || encoding.NULL_HASH;
  this.height = height != null ? height : -1;
  this.time = time || 0;
}
1361965
function addFilterRangeDate($form_field, $label, $db_field = null) {
        if(!$db_field) {
            $db_field = $form_field;
        }
        $gr = $this->form->putTbGroup($form_field)
            ->setLabel($label);
        $gr->putTbDate('from')
            ->setLabel('С')
            ->setWrapClass('col-md-6')
            ->setAppendClear();
        $gr->putTbDate('to')
            ->setLabel('по')
            ->setWrapClass('col-md-6')
            ->setAppendClear();
        $from = \Input::get($form_field . '.from');
        $to   = \Input::get($form_field . '.to');
        if($from) {
            $this->model->where(function ($query) use ($db_field, $from) {
                $query->where($db_field, '>=', \Carbon\Carbon::parse($from)
                    ->format('Y-m-d H:i:s'));
            });
        }
        if($to) {
            $this->model->where(function ($query) use ($db_field, $to) {
                $query->where($db_field, '<=', \Carbon\Carbon::parse($to)
                    ->format('Y-m-d H:i:s'));
            });
        }
    }
1161588
public static function validateLength($type, $value)
    {
        $value = trim($value);

        if (!strlen($value)) {
            return;
        }

        if (in_array($type, self::getDecimalTypes())) {
            if (!preg_match(self::REGEX_LENGTH_DOUBLE, $value)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_decimal_length', [
                    'type' => $type
                ]));
            }
        } else {
            if (!preg_match(self::REGEX_LENGTH_SINGLE, $value)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [
                    'type' => $type
                ]));
            }
        }
    }
1033399
function LENGTH_VALIDATOR(v) {
  v = (v || '').toString()
  var match = v.match(LENGTH_REGEXP)

  if (match) {
    var unit = match[1]
    if (!unit) {
      return {value: parseFloat(v)}
    }
    else if (SUPPORT_CSS_UNIT.indexOf(unit) > -1) {
      return {value: v}
    }
    else {
      return {
        value: parseFloat(v),
        reason: function reason(k, v, result) {
          return 'NOTE: unit `' + unit + '` is not supported and property value `' + v + '` is autofixed to `' + result + '`'
        }
      }
    }
  }

  return {
    value: null,
    reason: function reason(k, v, result) {
      return 'ERROR: property value `' + v + '` is not supported for `' + util.camelCaseToHyphened(k) + '` (only number and pixel values are supported)'
    }
  }
}
727267
function validate(values) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var s = this;

    var _tv4$validateMultiple = tv4.validateMultiple(values, s),
        valid = _tv4$validateMultiple.valid,
        errors = _tv4$validateMultiple.errors;

    if (valid) {
      return null;
    }

    var assign = options.assign,
        _options$name = options.name,
        name = _options$name === void 0 ? 'SchemaError' : _options$name;
    var _s$schema = s.schema,
        schema = _s$schema === void 0 ? {} : _s$schema;
    var error = new Error("Validation failed with schema: ".concat(schema.title || schema.id || schema.description));
    return Object.assign(error, {
      id: uuid.v4(),
      name: name,
      errors: errors,
      schema: schema,
      values: values,
      engine: 'tv4'
    }, assign);
  }
303074
static function diffField( $field1, $field2, $schema1Type, $schema2Type )
    {
        /* Type is always available */
        if ( $field1['type'] != $field2['type'] )
        {
            return array( 'different-options' => array( 'type' ), 'field-def' => $field2 );
        }

        $test_fields = array( 'default', 'not_null' );
        
        // Ignore length for int types
        if ( $field1['type'] === $field2['type'] && $field1['type'] !== 'int' )
            $test_fields[] = 'length';

        $different_options = array();

        foreach ( $test_fields as $test_field )
        {
            if ( isset( $field1[$test_field] ) )
            {
                if ( !isset( $field2[$test_field] ) ||
                     ( $field1[$test_field] != $field2[$test_field] ) )
                {
                    $different_options[] = $test_field;
                }
            }
            else
            {
                if ( isset( $field2[$test_field] ) && $field2[$test_field] )
                {
                    $different_options[] = $test_field;
                }
            }
        }

        if ( $different_options )
            return array( 'different-options' => $different_options, 'field-def' => $field2 );
        else
            return false;
    }
376418
def validate(self):
        """"""
        validate_rows_length(self.data, self.columns, exception=self.error)
        validate_categories_equal_entities(self.categories, self.entities,
                                           exception=self.error)
        if self.square:
            validate_square(self.data, exception=self.error)
1140263
function validateFields ( fldsMeta, fldsValue ) {
        return reduce(function ( acc, fldMeta, fldID ) {
            var value  = getOrNull( fldsValue, fldID )
              , errors = validateField( fldID, fldMeta, value );
            return t.merge( acc, errors );
        }, {}, fldsMeta );
    }
699528
function _isArrayValidate (type) {
  return (value) => {
    if (!Array.isArray(value)) {
      throw new Error(`Debe ser un Array.`)
    }
    value.forEach(val => {
      if ((type.key === 'STRING') && !Sequelize.Validator.len(`${val}`, 0, type.options.length)) {
        throw new Error(`Cada elemento debe ser una cadena de texto con un máximo de ${type.options.length} caracteres.`)
      }
      if ((type.key === 'TEXT') && !Sequelize.Validator.len(`${val}`, 0, 2147483647)) {
        throw new Error(`Cada elemento debe ser una cadena de texto.`)
      }
      if ((type.key === 'INTEGER') && !Sequelize.Validator.isInt(`${val}`)) {
        throw new Error(`Cada elemento debe ser de un número de tipo INTEGER.`)
      }
      if ((type.key === 'FLOAT') && !Sequelize.Validator.isFloat(`${val}`)) {
        throw new Error(`Cada elemento debe ser de un número de tipo FLOAT.`)
      }
      if ((type.key === 'BOOLEAN') && !Sequelize.Validator.isBoolean(`${val}`)) {
        throw new Error(`Cada elemento debe ser de tipo boolean.`)
      }
      if ((type.key === 'DATE') && !Sequelize.Validator.isDate(`${val}`)) {
        throw new Error(`Cada elemento debe ser una fecha válida.`)
      }
      if ((type.key === 'DATEONLY') && !Sequelize.Validator.isDate(`${val}`)) {
        throw new Error(`Cada elemento debe ser una fecha válida.`)
      }
      if ((type.key === 'TIME') && !moment(val, 'HH:mm:ss', true).isValid()) {
        throw new Error(`Cada elemento debe ser una hora válida.`)
      }
      if ((type.key === 'JSON') && (typeof val !== 'object')) {
        throw new Error(`Cada elemento debe ser un objeto de tipo JSON.`)
      }
      if ((type.key === 'JSONB') && (typeof val !== 'object')) {
        throw new Error(`Cada elemento debe ser un objeto de tipo JSON.`)
      }
      if ((type.key === 'UUID') && !Sequelize.Validator.isUUID(`${val}`)) {
        throw new Error(`Cada elemento debe ser una cadena de texto de tipo UUID.`)
      }
      if ((type.key === 'ENUM') && !Sequelize.Validator.isIn(`${val}`, type.values)) {
        throw new Error(`Cada elemento debe ser uno de los siguientes valores: ${type.values.toString()}.`)
      }
    })
  }
}
920322
protected function validateDigitsBetween($field, $value, $params)
    {
        $length = strlen((string) $value);

        return !preg_match('/[^0-9]/', $value) && $length >= $params[0] && $length <= $params[1];
    }
868516
public function validateDimensions($attribute, $value, $parameters)
    {
        if ($this->isValidFileInstance($value) && $value->getClientMimeType() === 'image/svg+xml') {
            return true;
        }

        if (! $this->isValidFileInstance($value) || ! $sizeDetails = @getimagesize($value->getRealPath())) {
            return false;
        }

        $this->requireParameterCount(1, $parameters, 'dimensions');

        [$width, $height] = $sizeDetails;

        $parameters = $this->parseNamedParameters($parameters);

        if ($this->failsBasicDimensionChecks($parameters, $width, $height) ||
            $this->failsRatioCheck($parameters, $width, $height)) {
            return false;
        }

        return true;
    }
135716
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        $finfo = \finfo_open(\FILEINFO_MIME);
        
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_invalid_file';
            }
            
            $mime = \finfo_file($finfo, $_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $mime = \finfo_buffer($finfo, $value);
        }
        
        \finfo_close($finfo);
        
        if(!$mime) {
            return 'formvalidator_make_invalid_file'; // @codeCoverageIgnore
        }
        
        $mime = \explode(';', $mime);
        $mime = \array_shift($mime);
        
        $val = \explode(',', $options);
        $result = \explode('/', $mime);
        
        foreach($val as $mimet) {
            $mimee = \explode('/', $mimet);
            if(\count($mimee) == 2 && \count($result) == 2) {
                if(($mimee[0] == "*" || $mimee[0] == $result[0]) && ($mimee[1] == "*" || $mimee[1] == $result[1])) {
                    return true;
                }
            }
        }
        
        return 'formvalidator_make_invalid_file';
    }
473742
def valid?
      return false if !@catalog_object_id.nil? && @catalog_object_id.to_s.length > 192
      return false if !@name.nil? && @name.to_s.length > 255
      type_validator = EnumAttributeValidator.new('String', ["UNKNOWN_TAX", "ADDITIVE", "INCLUSIVE"])
      return false unless type_validator.valid?(@type)
      return false if !@percentage.nil? && @percentage.to_s.length > 10
      return true
    end