Commit 3c80026e by Vladislav Lagunov

Исправленa ошибка в парсинге jsonapi-ресурсов

parent 6edd1d06
......@@ -142,6 +142,7 @@ export class JsonApiBase<A> {
return decoders.related(doc, res, key).chain(relatedRes => field.validate(doc, relatedRes));
}
case 'RelatedMany': {
if (isEmpty(field.child.desc)) return decoders.relatedLinkageCollection(res, key);
return decoders.relatedCollection(doc, res, key).chain(rs => either.traverse(rs, x => field.child.validate(doc, x)));
}
case 'WithDefault': {
......@@ -151,7 +152,10 @@ export class JsonApiBase<A> {
if (isEmpty(nested.desc)) return decoders.relatedLinkage(res, key).fold(() => success(field.defaultValue), success);
return decoders.related(doc, res, key).fold(() => success(field.defaultValue), relatedRes => nested.validate(doc, relatedRes));
}
case 'RelatedMany': return decoders.relatedCollection(doc, res, key).fold(() => success(field.defaultValue), rs => either.traverse(rs, x => nested.child.validate(doc, x)));
case 'RelatedMany': {
if (isEmpty(nested.child.desc)) return decoders.relatedLinkageCollection(res, key).fold(() => success(field.defaultValue), success);
return decoders.relatedCollection(doc, res, key).fold(() => success(field.defaultValue), rs => either.traverse(rs, x => nested.child.validate(doc, x)));
}
}
const result = helperRec(key, field.child, doc, res);
if (result instanceof Right) return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment