Source: models/documenttypeWithoutRequiredConstraint.js

/**
 * documenttype-without-required-constraint Model
 * Generated: 2025-04-01T19:44:53.353Z
 */

/**
 * documenttype-without-required-constraint model class
 */
export class DocumenttypeWithoutRequiredConstraint {
  /**
   * Create a new documenttype-without-required-constraint instance
   * @param {Object} data - Initial data
   */
  constructor(data = {}) {
    /**
     * Note Sails special attributes: autoIncrement
     * @type integer
     */
    this.id = data.id !== undefined ? data.id : undefined;
    /**
     * 
     * @type number
     */
    this.createdAt = data.createdAt !== undefined ? data.createdAt : undefined;
    /**
     * 
     * @type number
     */
    this.updatedAt = data.updatedAt !== undefined ? data.updatedAt : undefined;
    /**
     * The user who created this record JSON dictionary representing the **person** instance or FK when creating / updating / not populated
     * @type any
     */
    this.createdBy = data.createdBy !== undefined ? data.createdBy : undefined;
    /**
     * 
     * @type string
     */
    this.name = data.name !== undefined ? data.name : undefined;
    /**
     * 
     * @type string
     */
    this.description = data.description !== undefined ? data.description : undefined;
    /**
     * Whether this document type is featured in the UI
     * @type boolean
     */
    this.featured = data.featured !== undefined ? data.featured : undefined;
    /**
     * Whether this document is requested per year (e.g. balance sheets) or just once (e.g. ID card)
     * @type boolean
     */
    this.isYearlyDocument = data.isYearlyDocument !== undefined ? data.isYearlyDocument : undefined;
    /**
     * Whether multiple files can be uploaded for this document type
     * @type boolean
     */
    this.allowMultipleFiles = data.allowMultipleFiles !== undefined ? data.allowMultipleFiles : undefined;
    /**
     * JSON dictionary representing the **documentcategory** instance or FK when creating / updating / not populated
     * @type any
     */
    this.category = data.category !== undefined ? data.category : undefined;
    /**
     * Array of **documentrequestitem**'s or array of FK's when creating / updating / not populated
     * @type documentrequestitem[]
     */
    this.documentRequests = data.documentRequests !== undefined ? data.documentRequests : undefined;
  }

  /**
   * Validate the model
   * @returns {Object} - Validation result {valid: boolean, errors: Object}
   */
  validate() {
    const errors = {};


    return {
      valid: Object.keys(errors).length === 0,
      errors
    };
  }

  /**
   * Convert the model to a plain object
   * @returns {Object} - Plain object representation
   */
  toJSON() {
    const data = {};

    if (this.id !== undefined) {
      data.id = this.id;
    }
    if (this.createdAt !== undefined) {
      data.createdAt = this.createdAt;
    }
    if (this.updatedAt !== undefined) {
      data.updatedAt = this.updatedAt;
    }
    if (this.createdBy !== undefined) {
      data.createdBy = this.createdBy;
    }
    if (this.name !== undefined) {
      data.name = this.name;
    }
    if (this.description !== undefined) {
      data.description = this.description;
    }
    if (this.featured !== undefined) {
      data.featured = this.featured;
    }
    if (this.isYearlyDocument !== undefined) {
      data.isYearlyDocument = this.isYearlyDocument;
    }
    if (this.allowMultipleFiles !== undefined) {
      data.allowMultipleFiles = this.allowMultipleFiles;
    }
    if (this.category !== undefined) {
      data.category = this.category;
    }
    if (this.documentRequests !== undefined) {
      data.documentRequests = this.documentRequests;
    }

    return data;
  }

  /**
   * Create a documenttype-without-required-constraint instance from JSON data
   * @param {Object} data - JSON data
   * @returns DocumenttypeWithoutRequiredConstraint - New model instance
   */
  static fromJSON(data) {
    return new DocumenttypeWithoutRequiredConstraint(data);
  }
}

export default DocumenttypeWithoutRequiredConstraint;