You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
raqb/src/validators/is-remote-field-name.js

24 lines
616 B
JavaScript

"use strict";
const matchesFormat = require("@validatem/matches-format");
const isCollectionName = require("./is-collection-name");
const isLocalFieldName = require("./is-local-field-name");
module.exports = [
// FIXME: Validate format properly
matchesFormat(/^[^.]+\.[^.]+$/),
(string) => {
let [ collectionName, fieldName ] = string.split(".");
return {
collection: collectionName,
field: fieldName
};
},
{ // FIXME: Make any validation errors at this point be represented as virtual properties, as it's a parse result
collection: [ isCollectionName ],
field: [ isLocalFieldName ]
}
];