!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/node_modules/strapi/lib/services/entity-validator/   drwxr-xr-x
Free 13.12 GB of 57.97 GB (22.63%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     index.js (2.51 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/**
 * Entity validator
 * Module that will validate input data for entity creation or edition
 */
'use strict';

const _ = require('lodash');

const { yup, formatYupErrors } = require('strapi-utils');
const validators = require('./validators');

module.exports = ({ strapi }) => ({
  /**
   * Validate some input based on a model schema
   * @param {Object} model model schema
   * @param {Object} data input data
   */
  async validateEntity(model, data) {
    const validator = createValidator(model);

    return validator
      .validate(data, {
        abortEarly: false,
      })
      .catch(error => {
        throw strapi.errors.badRequest('ValidationError', { errors: formatYupErrors(error) });
      });
  },

  /**
   * Validate some input for updating based on a model schema
   * @param {Object} model model schema
   * @param {Object} data input data
   */
  async validateEntityUpdate(model, data) {
    const validator = createUpdateValidator(model);

    return validator
      .validate(data, {
        abortEarly: false,
      })
      .catch(error => {
        throw strapi.errors.badRequest('ValidationError', { errors: formatYupErrors(error) });
      });
  },
});

const isMedia = attr => {
  return (attr.collection || attr.model) === 'file' && attr.plugin === 'upload';
};

const createValidator = model => {
  return yup
    .object(
      _.mapValues(model.attributes, attr => {
        if (isMedia(attr)) {
          return yup.mixed().nullable();
        }

        const { required } = attr;

        let validator = createAttributeValidator(attr).nullable();

        if (_.has(attr, 'default')) {
          validator = validator.default(attr.default);
        }

        if (required) {
          return validator.notNil();
        }

        return validator;
      })
    )
    .required();
};

const createUpdateValidator = model => {
  return yup
    .object(
      _.mapValues(model.attributes, attr => {
        if (isMedia(attr)) {
          return yup.mixed().nullable();
        }

        const { required } = attr;

        const validator = createAttributeValidator(attr).nullable();

        if (required) {
          // on edit you can omit a key to leave it unchanged, but if it is required you cannot set it to null
          return validator.notNull();
        }

        return validator;
      })
    )
    .required();
};

/**
 * Validator for existing types
 */
const createAttributeValidator = attr => {
  if (_.has(validators, attr.type)) {
    return validators[attr.type](attr);
  }

  return yup.mixed();
};

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.019 ]--