All files / platform/modules/media/src/Validators getSignature.js

100% Statements 8/8
100% Branches 2/2
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30        1x 1x       23x         23x 7x     23x       28x           1x  
'use strict';
/** @typedef {import('@adonisjs/framework/src/Request')} Request */
/** @typedef {import('@adonisjs/framework/src/Response')} Response */
 
const _ = require('lodash');
const ValidatorAbstract = use('C2C/Abstracts/ValidatorAbstract');
 
class ValidateGetSignature extends ValidatorAbstract {
  get rules() {
    const rules = {
      fileName: `required|min:5|max:254|fileName`,
    };
 
    // The M2M flow requires a salonId in params
    if (!_.get(this.ctx, 'request.user')) {
      rules.salonId = 'required|string|max:254';
    }
 
    return rules;
  }
 
  get sanitizationRules() {
    return {
      salonId: 'trim',
    };
  }
}
 
module.exports = ValidateGetSignature;