Source: models/documentrequestitemWithoutRequiredConstraint.js

/**
 * documentrequestitem-without-required-constraint Model
 * Generated: 2025-04-01T19:44:53.352Z
 */

/**
 * documentrequestitem-without-required-constraint model class
 */
export class DocumentrequestitemWithoutRequiredConstraint {
  /**
   * Create a new documentrequestitem-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;
    /**
     * Required for yearly documents (e.g. 2023, 2024, 2025)
     * @type number
     */
    this.year = data.year !== undefined ? data.year : undefined;
    /**
     * 
     * @type string
     */
    this.status = data.status !== undefined ? data.status : undefined;
    /**
     * JSON dictionary representing the **documentrequest** instance or FK when creating / updating / not populated
     * @type any
     */
    this.documentRequest = data.documentRequest !== undefined ? data.documentRequest : undefined;
    /**
     * JSON dictionary representing the **documenttype** instance or FK when creating / updating / not populated
     * @type any
     */
    this.documentType = data.documentType !== undefined ? data.documentType : undefined;
    /**
     * Array of **documentsubmission**'s or array of FK's when creating / updating / not populated
     * @type documentsubmission[]
     */
    this.submissions = data.submissions !== undefined ? data.submissions : 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.year !== undefined) {
      data.year = this.year;
    }
    if (this.status !== undefined) {
      data.status = this.status;
    }
    if (this.documentRequest !== undefined) {
      data.documentRequest = this.documentRequest;
    }
    if (this.documentType !== undefined) {
      data.documentType = this.documentType;
    }
    if (this.submissions !== undefined) {
      data.submissions = this.submissions;
    }

    return data;
  }

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

export default DocumentrequestitemWithoutRequiredConstraint;