<commit_before>'use strict';

const joi = require('joi');

const RestController = require('../rest');

class PermissionController extends RestController {
  constructor() {
    super('AdminPermission');

    this.restRules = {
      create: {
        name: joi.string().min(3).required(),
        comment: joi.string().min(2).required()
      },
      update: {
        name: joi.string().min(3),
        comment: joi.string().min(2)
      }
    };
  }

}

module.exports = new PermissionController();<commit_msg>feat: add permission count check in permission controller<commit_after>'use strict';

const joi = require('joi');

const RestController = require('../rest');

class PermissionController extends RestController {
  constructor() {
    super('AdminPermission');

    this.restRules = {
      create: {
        name: joi.string().min(3).required(),
        comment: joi.string().min(2).required()
      },
      update: {
        name: joi.string().min(3),
        comment: joi.string().min(2)
      }
    };

    this.model.count().then((result) => {
      if (!result || result < 5) {
        throw 'Default admin permissions count error! Should greater or equal to 5, but got ' + result;
      }
    });
  }

}

module.exports = new PermissionController();
{'fraction_non_alphanumeric': 0.15694006309148265, 'fraction_numerical': 0.007886435331230283, 'mean_word_length': 2.765578635014837, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '792640', 'n_tokens_mistral': 378, 'n_tokens_neox': 368, 'n_words': 82}