コード例 #1
0
ファイル: newGame.js プロジェクト: michal-marciniec/codeball
  validators: {
    isDateValid({ date }) {
      return isPositiveInteger(date);
    },

    isDurationValid({ duration }) {
      return isPositiveInteger(duration);
    },

    isStartTimeValid({ hour, minute }) {
      return this.isHourValid({ hour }) && this.isMinuteValid({ minute });
    },

    isHourValid({ hour }) {
      return isInteger(hour) && isInRange(hour, 0, 23);
    },

    isMinuteValid({ minute }) {
      return isInteger(minute) && isInRange(minute, 0, 59);
    },

    isPitchIdValid({ pitchId }) {
      return isId(pitchId);
    }
  },

  toServerFormat(newGameModel) {
    const { date, duration, hour, minute, pitchId } = newGameModel;
    const startTimestamp = moment(date)
      .add(hour, 'hours')
コード例 #2
0
import { model } from 'utils';
import { isInteger } from 'utils/validation';
import { ENROLLMENT_STATUS_YES } from 'constants';

const EnrollAnotherUserModel = model({
  getDefaultAttributes: () => ({
    enrollmentStatus: ENROLLMENT_STATUS_YES,
    userId: undefined
  }),

  validators: {
    isUserIdValid({ userId }) {
      return isInteger(userId);
    }
  }
});

export default EnrollAnotherUserModel;