Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Weight Class Reference
Inheritance diagram for Weight:
AbstractImportValidator RowValidatorInterface AbstractValidator RowValidatorInterface ValidatorInterface ValidatorInterface ValidatorInterface Zend_Validate_Interface Zend_Validate_Interface Zend_Validate_Interface

Public Member Functions

 isValid ($value)
 
- Public Member Functions inherited from AbstractImportValidator
 init ($context)
 
- Public Member Functions inherited from AbstractValidator
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 getMessages ()
 
 hasMessages ()
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractValidator
static setDefaultTranslator (\Magento\Framework\Translate\AdapterInterface $translator=null)
 
static getDefaultTranslator ()
 
- Data Fields inherited from RowValidatorInterface
const ERROR_INVALID_SCOPE = 'invalidScope'
 
const ERROR_INVALID_WEBSITE = 'invalidWebsite'
 
const ERROR_INVALID_STORE = 'invalidStore'
 
const ERROR_INVALID_ATTR_SET = 'invalidAttrSet'
 
const ERROR_INVALID_TYPE = 'invalidType'
 
const ERROR_INVALID_CATEGORY = 'invalidCategory'
 
const ERROR_VALUE_IS_REQUIRED = 'isRequired'
 
const ERROR_TYPE_CHANGED = 'typeChanged'
 
const ERROR_SKU_IS_EMPTY = 'skuEmpty'
 
const ERROR_NO_DEFAULT_ROW = 'noDefaultRow'
 
const ERROR_CHANGE_TYPE = 'changeProductType'
 
const ERROR_DUPLICATE_SCOPE = 'duplicateScope'
 
const ERROR_DUPLICATE_SKU = 'duplicateSKU'
 
const ERROR_CHANGE_ATTR_SET = 'changeAttrSet'
 
const ERROR_TYPE_UNSUPPORTED = 'productTypeUnsupported'
 
const ERROR_ROW_IS_ORPHAN = 'rowIsOrphan'
 
const ERROR_INVALID_TIER_PRICE_QTY = 'invalidTierPriceOrQty'
 
const ERROR_INVALID_TIER_PRICE_SITE = 'tierPriceWebsiteInvalid'
 
const ERROR_INVALID_TIER_PRICE_GROUP = 'tierPriceGroupInvalid'
 
const ERROR_INVALID_TIER_PRICE_TYPE = 'tierPriceTypeInvalid'
 
const ERROR_TIER_DATA_INCOMPLETE = 'tierPriceDataIsIncomplete'
 
const ERROR_SKU_NOT_FOUND_FOR_DELETE = 'skuNotFoundToDelete'
 
const ERROR_SUPER_PRODUCTS_SKU_NOT_FOUND = 'superProductsSkuNotFound'
 
const ERROR_MEDIA_DATA_INCOMPLETE = 'mediaDataIsIncomplete'
 
const ERROR_INVALID_WEIGHT = 'invalidWeight'
 
const ERROR_EXCEEDED_MAX_LENGTH = 'exceededMaxLength'
 
const ERROR_INVALID_ATTRIBUTE_TYPE = 'invalidAttributeType'
 
const ERROR_INVALID_ATTRIBUTE_DECIMAL = 'invalidAttributeDecimal'
 
const ERROR_ABSENT_REQUIRED_ATTRIBUTE = 'absentRequiredAttribute'
 
const ERROR_INVALID_ATTRIBUTE_OPTION = 'absentAttributeOption'
 
const ERROR_DUPLICATE_UNIQUE_ATTRIBUTE = 'duplicatedUniqueAttribute'
 
const ERROR_INVALID_VARIATIONS_CUSTOM_OPTIONS = 'invalidVariationsCustomOptions'
 
const ERROR_INVALID_MEDIA_URL_OR_PATH = 'invalidMediaUrlPath'
 
const ERROR_MEDIA_URL_NOT_ACCESSIBLE = 'mediaUrlNotAvailable'
 
const ERROR_MEDIA_PATH_NOT_ACCESSIBLE = 'mediaPathNotAvailable'
 
const ERROR_DUPLICATE_URL_KEY = 'duplicatedUrlKey'
 
const ERROR_DUPLICATE_MULTISELECT_VALUES = 'duplicatedMultiselectValues'
 
const VALUE_ALL = 'all'
 
- Protected Member Functions inherited from AbstractValidator
 _clearMessages ()
 
 _addMessages (array $messages)
 
- Protected Attributes inherited from AbstractImportValidator
 $context
 
- Protected Attributes inherited from AbstractValidator
 $_translator = null
 
 $_messages = []
 
- Static Protected Attributes inherited from AbstractValidator
static $_defaultTranslator = null
 

Detailed Description

Definition at line 10 of file Weight.php.

Member Function Documentation

◆ isValid()

isValid (   $value)

{Returns true if and only if $value meets the validation requirementsIf $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed.

Parameters
mixed$value
Returns
boolean
Exceptions
Zend_Validate_ExceptionIf validation of $value is impossible
}

Implements Zend_Validate_Interface.

Definition at line 15 of file Weight.php.

16  {
17  $this->_clearMessages();
18  if (!empty($value['weight']) && (!is_numeric($value['weight']) || $value['weight'] < 0)
19  && $value['weight'] !== $this->context->getEmptyAttributeValueConstant()
20  ) {
21  $this->_addMessages(
22  [
23  sprintf(
24  $this->context->retrieveMessageTemplate(self::ERROR_INVALID_ATTRIBUTE_TYPE),
25  'weight',
26  'decimal'
27  )
28  ]
29  );
30  return false;
31  }
32  return true;
33  }
$value
Definition: gender.phtml:16

The documentation for this class was generated from the following file: