Skip to content

Commit fcbec6a

Browse files
features/support-string-collection-record-id (#238)
* Fixed validation for post and put method on save record * Removed logs
1 parent 15e444e commit fcbec6a

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/dist/arm-js-library.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from "axios";
22
import _ from "lodash";
33
import * as mobx from "mobx";
4-
import { v1, NIL } from "uuid";
4+
import { v1, validate, NIL } from "uuid";
55
import md5 from "md5";
66
import qs from "qs";
77
/**
@@ -540,7 +540,10 @@ Fix: Try adding ${collectionName} on your ARM config initialization.`;
540540
}
541541
);
542542
const collectionRecordId = getProperty(collectionRecord, "id");
543-
const isCollectionRecordIdValid = isNumber(collectionRecordId);
543+
const isCollectionRecordIdValid = isEqual(
544+
validate(collectionRecordId),
545+
false
546+
);
544547
return this._request({
545548
resourceMethod: isCollectionRecordIdValid ? "put" : "post",
546549
resourceName: collectionName,

packages/src/lib/api-resource-manager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import axios from 'axios'
3030
import _ from 'lodash'
3131
import * as mobx from 'mobx'
32-
import { v1 as uuidv1, NIL as NIL_UUID } from 'uuid'
32+
import { v1 as uuidv1, validate as uuidValidate, NIL as NIL_UUID } from 'uuid'
3333
import md5 from 'md5'
3434
import qs from 'qs'
3535

@@ -681,7 +681,10 @@ export default class ApiResourceManager {
681681
},
682682
)
683683
const collectionRecordId = getProperty(collectionRecord, 'id')
684-
const isCollectionRecordIdValid = isNumber(collectionRecordId)
684+
const isCollectionRecordIdValid = isEqual(
685+
uuidValidate(collectionRecordId),
686+
false,
687+
)
685688

686689
return this._request({
687690
resourceMethod: isCollectionRecordIdValid ? 'put' : 'post',

0 commit comments

Comments
 (0)