Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public validate(instance: any, schema: Schema): ValidatorResult {
Validator.prototype.customFormats.BigNumber = function(input) {
const regex = RegExp("^\\d+(\\.\\d+)?$");
// This allows undefined inputs, e.g. salt is not present sometimes.
return input === undefined || (input.isBigNumber && regex.test(input.toString()));
};
Validator.prototype.customFormats.wholeBigNumber = function(input) {
const regex = RegExp("^\\d+$");
return input && input.isBigNumber && regex.test(input.toString());
};
return this._validator.validate(instance, schema);
}
public validate(instance: any, schema: Schema): ValidatorResult {
Validator.prototype.customFormats.BigNumber = function(input) {
const regex = RegExp("^\\d+(\\.\\d+)?$");
// This allows undefined inputs, e.g. salt is not present sometimes.
return input === undefined || (input.isBigNumber && regex.test(input.toString()));
};
Validator.prototype.customFormats.wholeBigNumber = function(input) {
const regex = RegExp("^\\d+$");
return input && input.isBigNumber && regex.test(input.toString());
};
return this._validator.validate(instance, schema);
}
import macFormat from './macFormat';
import ipV6Format from './ipV6Format';
import ipV4Format from './ipV4Format';
import uuidFormat from './uuidFormat';
import emailFormat from './emailFormat';
import versionConstraintFormat from './versionConstraintFormat';
// Override jsonschema built in regex.
FORMAT_REGEXPS.email = emailFormat;
FORMAT_REGEXPS.ipv4 = ipV4Format;
FORMAT_REGEXPS.ipv6 = ipV6Format;
// Custom jsonschema validators.
Validator.prototype.customFormats.mac = macFormat;
Validator.prototype.customFormats.cidr = cidrFormat;
Validator.prototype.customFormats.uuid = uuidFormat;
Validator.prototype.customFormats['version-constraint'] = versionConstraintFormat;
const ajv = new Ajv({
meta: false,
extendRefs: true,
unknownFormats: 'ignore',
allErrors: true,
formats: {
cidr: cidrFormat,
mac: macFormat,
'version-constraint': versionConstraintFormat
}
});
// https://github.com/epoberezkin/ajv/issues/471
ajv.addMetaSchema(metaSchema);
import cidrFormat from './cidrFormat';
import macFormat from './macFormat';
import ipV6Format from './ipV6Format';
import ipV4Format from './ipV4Format';
import uuidFormat from './uuidFormat';
import emailFormat from './emailFormat';
import versionConstraintFormat from './versionConstraintFormat';
// Override jsonschema built in regex.
FORMAT_REGEXPS.email = emailFormat;
FORMAT_REGEXPS.ipv4 = ipV4Format;
FORMAT_REGEXPS.ipv6 = ipV6Format;
// Custom jsonschema validators.
Validator.prototype.customFormats.mac = macFormat;
Validator.prototype.customFormats.cidr = cidrFormat;
Validator.prototype.customFormats.uuid = uuidFormat;
Validator.prototype.customFormats['version-constraint'] = versionConstraintFormat;
const ajv = new Ajv({
meta: false,
extendRefs: true,
unknownFormats: 'ignore',
allErrors: true,
formats: {
cidr: cidrFormat,
mac: macFormat,
'version-constraint': versionConstraintFormat
}
});
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Validator } from 'jsonschema';
import { DefinitionsSchema } from './definitions.schema';
const v = new Validator();
Validator.prototype.customFormats.callback = (input) => typeof input === 'function';
// check if element have HTML in to string method ie HTMLDivElement
Validator.prototype.customFormats.HTMLContainer = (input) => typeof input === 'string' || (input.toString && input.toString().indexOf('HTML') > -1);
/**
* Returns validator instance
*/
export const getValidator = (schema) => {
return (params) => {
v.addSchema(DefinitionsSchema);
return v.validate(params, schema);
};
};
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Validator } from 'jsonschema';
import { DefinitionsSchema } from './definitions.schema';
const v = new Validator();
Validator.prototype.customFormats.callback = (input) => typeof input === 'function';
// check if element have HTML in to string method ie HTMLDivElement
Validator.prototype.customFormats.HTMLContainer = (input) => typeof input === 'string' || (input.toString && input.toString().indexOf('HTML') > -1);
/**
* Returns validator instance
*/
export const getValidator = (schema) => {
return (params) => {
v.addSchema(DefinitionsSchema);
return v.validate(params, schema);
};
};
module.exports = function(config) {
if (!config) {
console.error(config);
throw new Error("Config object not provided " + config);
}
var types = Validator.prototype.types;
types.regex = function testRegex (instance) {
return instance instanceof RegExp;
};
var v = new Validator();
var serverSchema = {
id: "/Server",
type: "object",
properties: {
domain: {type: "string"},
port: {type: "integer"},
timeout: {type: "integer"}
},
required: ['domain', 'port', 'timeout']
const Validator = require('jsonschema').Validator;
const AppUI = require('./ui').AppUI;
const util = require('util')
Validator.prototype.customFormats.isFunction = function(input) {
return typeof input === "function"
};
const configSchema = {
id: "/solcoverjs",
type: "object",
properties: {
client: {type: "object"},
cwd: {type: "string"},
host: {type: "string"},
port: {type: "number"},
providerOptions: {type: "object"},
silent: {type: "boolean"},