@@ -85,6 +85,7 @@ var singleInstance = (!CoreManager.get('IS_NODE'));
8585 * @constructor
8686 * @param {String } className The class name for the object
8787 * @param {Object } attributes The initial set of data to store in the object.
88+ * @param {Object } options The options for this object instance.
8889 */
8990export default class ParseObject {
9091 /**
@@ -97,7 +98,7 @@ export default class ParseObject {
9798 _objCount : number ;
9899 className : string ;
99100
100- constructor ( className : ?string | { className : string , [ attr : string ] : mixed } , attributes ?: { [ attr : string ] : mixed } ) {
101+ constructor ( className : ?string | { className : string , [ attr : string ] : mixed } , attributes ?: { [ attr : string ] : mixed } , options ?: { ignoreValidation : boolean } ) {
101102 var toSet = null ;
102103 this . _objCount = objectCount ++ ;
103104 if ( typeof className === 'string' ) {
@@ -113,8 +114,11 @@ export default class ParseObject {
113114 toSet [ attr ] = className [ attr ] ;
114115 }
115116 }
117+ if ( attributes && typeof attributes === 'object' ) {
118+ options = attributes ;
119+ }
116120 }
117- if ( toSet && ! this . set ( toSet ) ) {
121+ if ( toSet && ! this . set ( toSet , options ) ) {
118122 throw new Error ( 'Can\'t create an invalid Parse Object' ) ;
119123 }
120124 // Enable legacy initializers
@@ -626,12 +630,14 @@ export default class ParseObject {
626630 }
627631
628632 // Validate changes
629- var validation = this . validate ( newValues ) ;
630- if ( validation ) {
631- if ( typeof options . error === 'function' ) {
632- options . error ( this , validation ) ;
633+ if ( ! options . ignoreValidation ) {
634+ var validation = this . validate ( newValues ) ;
635+ if ( validation ) {
636+ if ( typeof options . error === 'function' ) {
637+ options . error ( this , validation ) ;
638+ }
639+ return false ;
633640 }
634- return false ;
635641 }
636642
637643 // Consolidate Ops
@@ -1359,11 +1365,11 @@ export default class ParseObject {
13591365 } else if ( classMap [ adjustedClassName ] ) {
13601366 parentProto = classMap [ adjustedClassName ] . prototype ;
13611367 }
1362- var ParseObjectSubclass = function ( attributes ) {
1368+ var ParseObjectSubclass = function ( attributes , options ) {
13631369 this . className = adjustedClassName ;
13641370 this . _objCount = objectCount ++ ;
13651371 if ( attributes && typeof attributes === 'object' ) {
1366- if ( ! this . set ( attributes || { } ) ) {
1372+ if ( ! this . set ( attributes || { } , options ) ) {
13671373 throw new Error ( 'Can\'t create an invalid Parse Object' ) ;
13681374 }
13691375 }
0 commit comments