Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (! date_str ) throw new Error("date needs to be defined");
date_str = req.user.company.normalise_date(date_str);
// Ensure that normalisation went OK
if (! validator.isDate(date_str)) throw new Error("Invalid date format");
} catch (e) {
console.log('Got an error ' + e);
req.session.flash_error(label + ' should be a date');
}
}
date_validator(from_date, 'From date');
if ( !validator.matches(from_date_part, /^[123]$/)
|| !validator.matches(to_date_part, /^[123]$/)
){
req.session.flash_error('Incorrect day part');
}
date_validator(to_date, 'To date');
// Check if it makes sence to continue validation (as following code relies on
// to and from dates to be valid ones)
if ( req.session.flash_has_errors() ) {
throw new Error( 'Got validation errors' );
}
// Convert dates inot format used internally
from_date = req.user.company.normalise_date(from_date);
to_date = req.user.company.normalise_date(to_date);
}
// check that collaborator's access values are valid
flag=true;
for(i=0;i Access values ok");
// check that the list of annotations contains at least 1 volume-type entry
flag = false;
for(i=0;i
function isBlockOrderId (str) {
if (matches(str, /^[a-zA-Z0-9_-]+$/)) {
return str
}
throw new ValidationError('Block order IDs only contain upper and lower case letters, numbers, dashes (-) and underscores (_).')
}
validator.extend('isSlug', function isSlug(str) {
return validator.matches(str, /^[a-z0-9\-_]+$/);
});
return validator.equals(value, otherValue);
}
case 'numeric': {
return validator.isNumeric(value);
}
case 'date': {
return validator.isDate(value);
}
case 'alphanumeric': {
return validator.isAlphanumeric(value);
}
case 'alpha': {
return validator.isAlpha(value);
}
case 'regex': {
return validator.matches(value, config.pattern);
}
case 'max': {
return value.length <= config.length;
}
default: {
throw new Error(`Unknown validation rule used: '${rule}'`);
}
}
}
firstname: req.body.firstname,
lastname: req.body.lastname,
email: req.body.email
}
} else {
var inputValue = {
nonIndiv: 'true',
orgname: req.body.orgname,
license: req.body.license,
email: req.body.email,
stock: req.body.stock
}
}
partials = req.app.get('partials');
const email = validator.isEmail(req.body.email);
const password = validator.matches(req.body.pwd, passExpression);
var count = 0;
if (req.body.usertype === 'Individual') {
var userObj = {
user_type: req.body.usertype,
email: req.body.email,
password: req.body.pwd,
indiv: {
name: req.body.firstname + ' ' + req.body.lastname
},
notification_flag: 'N',
active_flag: 'N'
}
if (req.body.firstname.length < 3) {
return res.render('auth/signup', { title: 'Signup', alertMessage: 'first name must contain minimum 3 chars.', inputValue: inputValue });
} else if (req.body.lastname.length < 3) {
return res.render('auth/signup', { title: 'Signup', alertMessage: 'last name must contain minimum 3 chars.', inputValue: inputValue });
const addProject = async (
root,
{ input },
{
hasPermission,
sqlClient,
models,
},
) => {
await hasPermission('project', 'add');
if (validator.matches(input.name, /[^0-9a-z-]/)) {
throw new Error(
'Only lowercase characters, numbers and dashes allowed for name!',
);
}
if (!isValidGitUrl(input.gitUrl)) {
throw new Error('The provided gitUrl is invalid.',);
}
let keyPair = {};
try {
const privateKey = R.cond([
[R.isNil, generatePrivateKey],
[R.isEmpty, generatePrivateKey],
[R.T, sshpk.parsePrivateKey],
])(R.prop('privateKey', input));
function parseColumnDefinition(options) {
var
name = options.name,
type = options.type.toLowerCase(),
primaryKey = options.primaryKey ? true : false,
autoIncrement = primaryKey && (options.autoIncrement ? true : false),
allowNull = options.allowNull ? true : false,
index = options.index ? true : false,
unique = options.unique ? true : false,
defaultValue = options.defaultValue,
validate = options.validate,
defaultValueIsFunction = typeof defaultValue === 'function';
if (!name || !validator.matches(name, /^[a-zA-Z0-9\_]+$/)) {
throw new Error('name is invalid: ' + name);
}
return {
name: name,
type: type,
booleanType: type === 'bool' || type === 'boolean',
primaryKey: primaryKey,
autoIncrement: autoIncrement,
allowNull: allowNull,
index: index,
unique: unique,
defaultValue: defaultValue,
validate: validate,
defaultValueIsFunction: defaultValueIsFunction
};
}
.custom((value, { req }) => {
if (req.body.role && req.body.role === 'caterer') {
if (!req.body.businessName) throw new Error('Business name must be specified');
if (value.length > 60) throw new Error('Business name must not be more than 60 characters');
if (!validator.matches(value, /^[a-z0-9 (),.'-\s]+$/i)) {
throw new Error('Business name can only contain letters, spaces, and the characters (,.\'-)');
}
return notEmpty(value, 'Business name field cannot be left blank');
}
return true;
}),
check('address')
validator.extend('isSlug', function isSlug(str) {
return validator.matches(str, /^[a-z0-9\-_]+$/);
});