public function price(array $values)
    {
        if (count($values) != 1) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $components = array_map('trim', explode('|', reset($values)));

        if (count($components) > 2) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        if (!is_numeric($components[0])) {
            return $this->translation->text('@field must be numeric', array(
                '@field' => $this->translation->text('Price')));
        }

        if (strlen($components[0]) > 8) {
            return $this->translation->text('@field must not be longer than @max characters', array(
                '@max' => 8,
                '@field' => $this->translation->text('Price')));
        }

        if (empty($components[1])) {
            $components[1] = $this->currency->getDefault();
        }

        $currency = $this->currency->get($components[1]);

        if (empty($currency)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Currency')));
        }

        return true;
    }
public function price(array $values)
    {
        if (count($values) != 1) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $components = array_map('trim', explode('|', reset($values)));

        if (count($components) > 2) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        if (!is_numeric($components[0])) {
            return $this->translation->text('@field must be numeric', array(
                '@field' => $this->translation->text('Price')));
        }

        if (strlen($components[0]) > 8) {
            return $this->translation->text('@field must not be longer than @max characters', array(
                '@max' => 8,
                '@field' => $this->translation->text('Price')));
        }

        if (empty($components[1])) {
            $components[1] = $this->currency->getDefault();
        }

        $currency = $this->currency->get($components[1]);

        if (empty($currency)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Currency')));
        }

        return true;
    }
public function price ( array $ values ) { if ( count ( $ values ) != 1 ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } $ components = array_map ( 'trim' , explode ( '|' , reset ( $ values ) ) ) ; if ( count ( $ components ) > 2 ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } if ( ! is_numeric ( $ components [ 0 ] ) ) { return $ this -> translation -> text ( '@field must be numeric' , array ( '@field' => $ this -> translation -> text ( 'Price' ) ) ) ; } if ( strlen ( $ components [ 0 ] ) > 8 ) { return $ this -> translation -> text ( '@field must not be longer than @max characters' , array ( '@max' => 8 , '@field' => $ this -> translation -> text ( 'Price' ) ) ) ; } if ( empty ( $ components [ 1 ] ) ) { $ components [ 1 ] = $ this -> currency -> getDefault ( ) ; } $ currency = $ this -> currency -> get ( $ components [ 1 ] ) ; if ( empty ( $ currency ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'Currency' ) ) ) ; } return true ; }
Validates a price condition
@param array $values
@return boolean|string
Validates a price condition