Validates subscription data before creating Outbound message
875
def post(self, request, *args, **kwargs):
        
        schedule_disable.delay(kwargs["subscription_id"])
        return Response({"accepted": True}, status=201)
831444
function validateObjectList( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        if ( count( $persistentData['node_list'] ) == 0 )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must select one or more node(s)/subtree(s) for export.' ) );
            return false;
        }

        return true;
    }
81297
function validate (payload) {
  var notification = payload.notification
  var message = payload.message
  if (!notification && !message) {
    throw new JError.InvalidArgumentError('Either or both notification and message must be set.')
  }
}
417091
def _validate(self, msg):
    
    if not isinstance(msg, self._message_type):
      raise TypeError('Expected a %s instance for %s property',
                      self._message_type.__name__,
                      self._code_name or self._name)
637306
def _validate(self, writing=False):
        """"""
        box_ids = [box.box_id for box in self.box]
        if len(box_ids) != 1 or box_ids[0] != 'flst':
            msg = ("Fragment table boxes must have a single fragment list "
                   "box as a child box.")
            self._dispatch_validation_error(msg, writing=writing)
568218
function PushDataValidator(data) {
  MessagingUserStatus.call(this, 'push validator');

  if(data.deviceType != "ios" && data.deviceType != "android") {
    // Device type specification is invalid
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid device type: ' + data.deviceType;

  } else if(!helpers.validateMessage(data.deviceToken)) {
    // Device token is invalid
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid device token: ' + data.deviceToken;

  } else if(!helpers.validateMessage(data.message)) {
    // Message string is invalid
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid message: ' + data.message;

  } else {
    // Input data is valid
    this.state.code = this.StatusCodes.VALID;
    this.state.message = 'Ok';
  }
}
639838
protected void validate(BasicMessageWithExtraData<REQ> envelope) {
        if (envelope.getBasicMessage().getResourceId() == null) {
            throw new IllegalArgumentException(
                    String.format("resourceId of a [%s] cannot be null", envelope.getClass().getName()));
        }
    }
299444
def validate(self, protocol_version):
        """"""
        const = get_const(protocol_version)
        valid_node_ids = vol.All(vol.Coerce(int), vol.Range(
            min=0, max=BROADCAST_ID, msg='Not valid node_id: {}'.format(
                self.node_id)))
        valid_child_ids = vol.All(vol.Coerce(int), vol.Range(
            min=0, max=SYSTEM_CHILD_ID, msg='Not valid child_id: {}'.format(
                self.child_id)))
        if self.type in (const.MessageType.internal, const.MessageType.stream):
            valid_child_ids = vol.All(vol.Coerce(int), vol.In(
                [SYSTEM_CHILD_ID],
                msg='When message type is {}, child_id must be {}'.format(
                    self.type, SYSTEM_CHILD_ID)))
        if (self.type == const.MessageType.internal and
                self.sub_type in [
                    const.Internal.I_ID_REQUEST,
                    const.Internal.I_ID_RESPONSE]):
            valid_child_ids = vol.Coerce(int)
        valid_types = vol.All(vol.Coerce(int), vol.In(
            [member.value for member in const.VALID_MESSAGE_TYPES],
            msg='Not valid message type: {}'.format(self.type)))
        if self.child_id == SYSTEM_CHILD_ID:
            valid_types = vol.All(vol.Coerce(int), vol.In(
                [const.MessageType.presentation.value,
                 const.MessageType.internal.value,
                 const.MessageType.stream.value],
                msg=(
                    'When child_id is {}, {} is not a valid '
                    'message type'.format(SYSTEM_CHILD_ID, self.type))))
        valid_ack = vol.In([0, 1], msg='Not valid ack flag: {}'.format(
            self.ack))
        valid_sub_types = vol.In(
            [member.value for member
             in const.VALID_MESSAGE_TYPES.get(self.type, [])],
            msg='Not valid message sub-type: {}'.format(self.sub_type))
        valid_payload = const.VALID_PAYLOADS.get(
            self.type, {}).get(self.sub_type, '')
        schema = vol.Schema({
            'node_id': valid_node_ids, 'child_id': valid_child_ids,
            'type': valid_types, 'ack': valid_ack, 'sub_type': valid_sub_types,
            'payload': valid_payload})
        to_validate = {attr: getattr(self, attr) for attr in schema.schema}
        return schema(to_validate)
1150346
def _validate(self, writing=False):
        """"""
        for box in self.DR:
            if box.box_id != 'url ':
                msg = ('Child boxes of a data reference box can only be data '
                       'entry URL boxes.')
                self._dispatch_validation_error(msg, writing=writing)
679627
function handleDatabeforeSubmission($thisForm, amount, event) {
      var currency = $thisForm.find("option:selected").val();
      var givingType = $thisForm.data('giving-type');
      var cartId = $thisForm.data('cart-id');
      var clientId = $thisForm.data('client-id');
      var rowID = $thisForm.parents('.paragraph--membership-signup').attr('id');

      /* Send data */
      if (validateAmount(amount)) {
        $thisForm.find(".form-error").removeClass('show-error');
        nextStepHandler(event, currency, amount, givingType, cartId, clientId, rowID);
      } else {
        $thisForm.find(".form-error").addClass('show-error');
      }
    }
729367
protected void resetCreateSubscriptionMessage(MESubscription subscription, boolean isLocalBus)
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "resetCreateSubscriptionMessage", new Object[]{subscription, new Boolean(isLocalBus)});

    // Reset the state
    reset();

    // Indicate that this is a create message    
    iSubscriptionMessage.setSubscriptionMessageType(
      SubscriptionMessageType.CREATE);

    // Add the subscription related information.
    iTopics.add(subscription.getTopic());
    
    if(isLocalBus)
    {
      //see defect 267686:
      //local bus subscriptions expect the subscribing ME's
      //detination uuid to be set in the iTopicSpaces field
      iTopicSpaces.add(subscription.getTopicSpaceUuid().toString());
    }
    else
    {
      //see defect 267686:
      //foreign bus subscriptions need to set the subscribers's topic space name.
      //This is because the messages sent to this topic over the link
      //will need to have a routing destination set, which requires
      //this value.
      iTopicSpaces.add(subscription.getTopicSpaceName().toString());
    }
    
    iTopicSpaceMappings.add(subscription.getForeignTSName());

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "resetCreateSubscriptionMessage");
  }
180294
def _validate(cls, message):
        
        valid = False
        if(('name' in message and 'value' in message) or
                ('id' in message and 'data' in message)):
            valid = True
        return valid
488842
public final SubscriptionMessage makeInboundSubscriptionMessage() throws IncorrectMessageTypeException {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "makeInboundSubscriptionMessage");

    SubscriptionMessage subMessage = null;

    /* If the message has never been flattened/encoded, it will already be  */
    /* a SubscriptionMessage so we can just proceed with this recast.       */
    /* Otherwise we will need to convert it into a SubscriptionMessage.     */
    if (this instanceof SubscriptionMessageImpl) {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Incoming message is already a SubscriptionMessage");
      subMessage = (SubscriptionMessageImpl)this;
    }
    /* The incoming message should be a SUBSCRIPTION message.                 */
    else if (getJsMessageType() == MessageType.SUBSCRIPTION) {
      // Ensure pending changes are flushed to JMF before passing the JMO around
      updateDataFields(MfpConstants.UDF_MAKE_INBOUND_OTHER);
      subMessage = new SubscriptionMessageImpl(jmo);
    }
    /* If the incoming message is some other sort of message it is an error.  */
    else {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Not a SUBSCRIPTION Message");
      String exString = nls.getFormattedMessage("UNEXPECTED_MESSAGE_TYPE_CWSIF0102"
                                               ,new Object[] {getJsMessageType(), MessageType.SUBSCRIPTION}
                                               ,"The Message is not a SUBSCRIPTION Message");
      throw new IncorrectMessageTypeException(exString);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "makeInboundSubscriptionMessage");
    return subMessage;
  }
1000295
function buildSubmissionReceivedMessage(subscribers, formName, formSubmission) {
  var msg = {};
  msg.subscribers = subscribers;
  msg.formId = formSubmission.formId;
  msg.appId = formSubmission.appId;
  msg.attachmentUrl = getAttachmentUrl(formSubmission);
  msg.formName = formName || "UNKNOWN FORM NAME";
  msg.submissionStatus = formSubmission.status;
  msg.appEnvironment = formSubmission.appEnvironment;
  msg.submissionStarted = formSubmission.submissionStartedTimestamp;
  msg.submissionCompleted = formSubmission.submissionCompletedTimestamp;
  msg.submissionId = formSubmission._id;
  msg.deviceIPAddress = formSubmission.deviceIPAddress;
  msg.deviceId = formSubmission.deviceId;
  msg.submittedFields = [];

  var form = formSubmission.formSubmittedAgainst;

  // build helper structures
  var fieldPageMap = {};
  var fieldSectionMap = {};
  var sectionsInPage = {};
  form.pages.forEach(function(page) {
    var currentSectionId = 'initial';
    sectionsInPage[page._id] = [currentSectionId];
    page.fields.forEach(function(field) {
      fieldPageMap[field._id] = page._id;
      if (field.type === 'sectionBreak') {
        currentSectionId = field._id;
        sectionsInPage[page._id].push(currentSectionId);
      } else {
        fieldSectionMap[field._id] = currentSectionId;
      }
    });
  });

  // get structured form fields
  var pages = getStructuredFields(formSubmission, fieldPageMap, fieldSectionMap);

  // construct message
  form.pages.forEach(function(page) {
    //is this page in submission?
    if (pages[page._id]) {
      var sections = sectionsInPage[page._id];
      sections.forEach(function(section) {
        var repSections = pages[page._id][section];
        if (repSections) {
          if (repSections.length === 1) {
            repSections[0].forEach(function(formField) {
              msg.submittedFields.push(getFieldMsg(formField, formSubmission));
            });
          } else {
            repSections.forEach(function(repSection, index) {
              msg.submittedFields.push(getField(section, formSubmission).name + ' - ' + (index + 1) + ':');
              repSection.forEach(function(formField) {
                msg.submittedFields.push(getFieldMsg(formField, formSubmission));
              });
            });
          }
        }
      });
    }
  });

  return msg;
}
1044312
function(s, args, ef) {

        this.log(this.type + "->" + "sub: " +  s.id);

        var ret;

        ret = s.notify(args, this);

        if (false === ret || this.stopped > 1) {
            this.log(this.type + " cancelled by subscriber");
            return false;
        }

        return true;
    }
233366
public function validate() {

		if ($this->getConsumedUnits() === null) {
			throw new ValidationException("'consumedUnits' can't be null", 'consumedUnits', $this);
		}
		if ($this->getExternalId() === null) {
			throw new ValidationException("'externalId' can't be null", 'externalId', $this);
		}
		if ($this->getMetric() === null) {
			throw new ValidationException("'metric' can't be null", 'metric', $this);
		}
		if ($this->getSubscription() === null) {
			throw new ValidationException("'subscription' can't be null", 'subscription', $this);
		}
	}
446389
function onMessage (subscription, fullMessage) {
  let msg = null
  try {
    msg = JSON.parse(fullMessage.body)
  } catch (fullMessage) {
    console.tron.error(`Error parsing : ${fullMessage}`)
  }
  if (msg) {
    return em({ subscription, msg })
  }
}