当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript check.check函数代码示例

本文整理汇总了TypeScript中meteor/check.check函数的典型用法代码示例。如果您正苦于以下问题:TypeScript check函数的具体用法?TypeScript check怎么用?TypeScript check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

 setComment: function(id: string, comment: string) {
   check(comment, String);
   check(id, String);
   comment = comment.replace(/[^\w\s]/gi, '');
   let character = Characters.findOne({
     uid: this.userId
   });
   if (!character) {
     throw new Meteor.Error("error", "The server does not know about your character.");
   }
   let fit = _.findWhere(character.fits, {
     fid: id,
   });
   if (!fit) {
     throw new Meteor.Error("error", "Can't find that fit in your fits.");
   }
   return Characters.update({
     _id: character._id,
     "fits.fid": id
   }, {
     $set: {
       "fits.$.comment": comment
     }
   });
 },
开发者ID:paralin,项目名称:evewaitlist,代码行数:25,代码来源:methodsb.ts

示例2: function

	addMessageTask: function (taskId: string, message: string) {
		check(taskId, String);
		check(message, String);
		if (!message.length || message.length < 3) {
			throw new Meteor.Error('400', 'message-to-short');
		}
		if (message.length > 1024) {
			throw new Meteor.Error('400', 'message-to-long');
		}
		// verif user & task
		let user = Meteor.user();
		if (!user) {
			throw new Meteor.Error('403', 'not-authorized');
		}
		let task = Tasks.find({
			_id: taskId,
			$or: [
				{ owner: this.userId },
				{ 'targets.userId': this.userId }
			]
		});
		if (!task) {
			throw new Meteor.Error('403', 'not-authorized');
		}
		Tasks.update(taskId, {
			$push: {
				conversation: {
					message: message,
					createdAt: new Date(),
					owner: user._id,
					ownerEmail: user.emails[0].address
				}
			}
		});
	},
开发者ID:djulls07,项目名称:projects-manager,代码行数:35,代码来源:tasks.ts

示例3: check

	createNewConversation:function(title:string, sender:string, recipient:string, message:string){
		check(title, String); check(sender, String); check(recipient, String); check(message, String);
		var dateCreated = moment().format('MMMM Do YYYY, h:mm:ss a');

		var first = Users.find({"_id":sender}).fetch()[0].profile.firstname;
		var last = Users.find({"_id":sender}).fetch()[0].profile.lastname;
		var senderName = first + " " + last;

		ConversationStreams.insert({
			title:title,
			created: dateCreated,
			subscribers:[
			{'user':sender, 'unread':0, 'subscribed':1},
			{'user':recipient, 'unread':1, 'subscribed':1}
			],
			messages:[
			new Message(dateCreated, senderName, message)
			]
		}, (err, insertionID)=>{
			if(err){
					// message insertion failed
					console.log(err);
				}else{
					// Insert new conversation reference in the users subscriptions
					updateUserSubscription(sender, insertionID, 'sender');
					updateUserSubscription(recipient, insertionID, 'recipient');
					// console.log('maybe we got it right!');
				}
			});
	},
开发者ID:gab3alm,项目名称:lemonaidev3,代码行数:30,代码来源:conversation-methods.ts

示例4: function

  invite: function (trackId:string, userId:string) {
    check(trackId, String);
    check(userId, String);

    let track = Tracks.collection.findOne(trackId);

    if (!track)
      throw new Meteor.Error('404', 'No such track!');

    if (track.public)
      throw new Meteor.Error('400', 'That track is public. No need to invite people.');

    if (track.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');

    if (userId !== track.owner && (track.invited || []).indexOf(userId) == -1) {
      Tracks.collection.update(trackId, {$addToSet: {invited: userId}});

      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));

      if (Meteor.isServer && to) {
        Email.send({
          from: 'noreply@beetrut.com',
          to: to,
          replyTo: from || undefined,
          subject: 'TRACK: ' + track.name,
          text: `Hi, I just invited you to ${track.name} on Beetrut.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
开发者ID:harishmaiya,项目名称:gundmi48-gadikatte58,代码行数:33,代码来源:tracks.methods.ts

示例5: function

  invite: function (partyId:string, userId:string) {
    check(partyId, String);
    check(userId, String);
 
    let party = Parties.findOne(partyId);
 
    if (!party)
      throw new Meteor.Error('404', 'No such party!');
 
    if (party.public)
      throw new Meteor.Error('400', 'That party is public. No need to invite people.');
 
    if (party.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');
 
    if (userId !== party.owner && (party.invited || []).indexOf(userId) == -1) {
      Parties.update(partyId, {$addToSet: {invited: userId}});
 
      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));
 
      if (Meteor.isServer && to) {
        Email.send({
          from: 'noreply@socially.com',
          to: to,
          replyTo: from || undefined,
          subject: 'PARTY: ' + party.name,
          text: `Hi, I just invited you to ${party.name} on Socially.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
开发者ID:ElijahWolfe,项目名称:socially,代码行数:33,代码来源:methods.ts

示例6: function

    foo: function (arg1: string, arg2: number[]) {
        check(arg1, String);
        check(arg2, [Number]);

        var you_want_to_throw_an_error = true;
        if (you_want_to_throw_an_error)
            throw new Meteor.Error("404", "Can't find my pants");
        return "some return value";
    },
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:9,代码来源:meteor-tests.ts

示例7: constructor

  constructor(
    hCurObserver: Meteor.LiveQueryHandle,
    hAutoNotify?: Tracker.Computation) {

    check(hAutoNotify, Match.Optional(Tracker.Computation));
    check(hCurObserver, Match.Where(function(observer) {
      return !!observer.stop;
    }));

    this._hAutoNotify = hAutoNotify;
    this._hCurObserver = hCurObserver;
  }
开发者ID:GuillaumeM69,项目名称:angular2-meteor,代码行数:12,代码来源:cursor_handle.ts

示例8: function

  reply: function(partyId: string, rsvp: string) {
    check(partyId, String);
    check(rsvp, String);

    if(!this.userId) {
      throw new Meteor.Error('403', 'You must be logged in to reply');
    }

    if(['yes', 'no', 'maybe'].indexOf(rsvp) === -1) {
      throw new Meteor.Error('400', 'Invalid RSVP');
    }

    let party = Parties.findOne(partyId);

    if(!party) {
      throw new Meteor.Error('404', 'No such party!');
    }

    if(party.owner === this.userId) {
      throw new Meteor.Error('500', 'You are the owner!');
    }

    if(!party.public && (!party.invited || party.invited.indexOf(this.userId) === -1)) {
      throw new Meteor.Error('403', 'No such party!'); // It's private but let's not tell user that
    }

    let rsvpIndex = party.rsvps ? party.rsvps.findIndex((rsvp) => rsvp.userId === this.userId) : -1;

    if(rsvpIndex !== -1) {
      // update existing rsvp entry
      if(Meteor.isServer) {
        // update the appropriate rsvp entry with $
        Parties.update(
          {_id: partyId, 'rsvps.userId': this.userId},
          {$set: {'rsvps.$.response': rsvp}}
        );
      }
      else {
        // minimongo doesn't yet support $ in modifier. as a temporary
        // workaround, make a modifier that uses an index. this is
        // safe on the client since there's only one thread.
        let modifier = {$set: {} };
        modifier.$set['rsvps.' + rsvpIndex + '.response'] = rsvp;
        Parties.update(partyId, modifier);
      }
    }
    else {
      // add new rsvp entry
      Parties.update(partyId, {
        $push: {rsvps: {userId: this.userId, response: rsvp}}
      });
    }
  }
开发者ID:verdantred,项目名称:torni,代码行数:53,代码来源:methods.ts

示例9: function

  sendAnswer: function (ticket: Ticket) {

    check(ticket._id, String);
    check(ticket.nbTokensToGive, Number);
    check(ticket.answerComment, String);

    Tickets.update(ticket._id, {
      $set: {
        nbTokensToGive: ticket.nbTokensToGive,
        answerComment: ticket.answerComment
      }
    });

    //TODO : send an email
  }
开发者ID:BdEINSALyon,项目名称:LaundryHelp,代码行数:15,代码来源:methods.ts


注:本文中的meteor/check.check函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。