public void validate ( ) throws OValidationException { if ( ODatabaseRecordThreadLocal . INSTANCE . isDefined ( ) && ! getDatabase ( ) . isValidationEnabled ( ) ) return ; checkForLoading ( ) ; checkForFields ( ) ; if ( _clazz != null ) { if ( _clazz . isStrictMode ( ) ) { // CHECK IF ALL FIELDS ARE DEFINED for ( String f : fieldNames ( ) ) { if ( _clazz . getProperty ( f ) == null ) throw new OValidationException ( "Found additional field '" + f + "'. It cannot be added because the schema class '" + _clazz . getName ( ) + "' is defined as STRICT" ) ; } } for ( OProperty p : _clazz . properties ( ) ) { validateField ( this , p ) ; } } }
Validates the record following the declared constraints defined in schema such as mandatory notNull min max regexp etc . If the schema is not defined for the current class or there are not constraints then the validation is ignored .