1

ImageModel

Objective
  • Model
    • ImageModel
  1. function ImageModel(name = null) {
  2.     Model.call(this, name);
  3.  
  4.     this._value = {
  5.         image:  { image: null, size: [0, 0] }
  6.     };
  7. }
  8.  
  9. ImageModel.prototype = Object.create(Model.prototype);
  10.  
  11. Object.defineProperty(ImageModel.prototype, 'constructor', { value: ImageModel, enumerable: false, writable: true });
  12.  
  13. ImageModel.prototype.validateValue = function(prop, val) {
  14.     if (prop == 'image') {
  15.         if (typeof val !== 'object')
  16.             return false;
  17.  
  18.         const { image, size } = val;
  19.  
  20.         if (image === null)
  21.             return true;
  22.  
  23.         if (! (Array.isArray(image) && Validator.validateImageDataURL(image[0]) && Number.isInteger(image[1]) && Number.isInteger(image[2]) && image[1] >= 0 && image[2] >= 0))
  24.             return false;
  25.  
  26.         if (! (Array.isArray(size) && Number.isInteger(size[0]) && Number.isInteger(size[1]) && size[0] >= 0 && size[1] >= 0))
  27.             return false;
  28.  
  29.         return true;
  30.     }
  31.  
  32.     return true;
  33. }
SEE ALSO

Model, VideoModel

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].