Probably i found solution.
modification in model definition:
MyModel = Backbone.RelationalModel.extend({
idAttribute : 'id', //here i added declaration of id field
urlRoot : '/api/v1/SampleModel/',
relations : [
{
type: Backbone.HasOne,
key: 'box',
relatedModel: 'BoxModel',
includeInJSON: 'resource_uri' // changed 'id' to 'resource_uri' probably it's not required at all
}],
validate : function(attr)
{
if(!attr.name)
{
console.log('attr name validation fail');
return "C mon! name is srsly required!";
}
if(!attr.box)
{
console.log('attr box validation fail');
console.log(attr.box);
return "Damn! you forgot to set box!";
}
}
});
in view, i set in model just id instead resource_uri:
var BoxUri = '3'
var NewModel = new MyModel();
NewModel.set('box',BoxUri);
NewModel.set('name','new name for model');
after these two modifications, validation started working.