<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2014, Joyent, Inc.
 */

/*
 * All validation related functions. They mostly apply to CreateVm and UpdateVm
 */


var assert = require('assert');
var restify = require('restify');
var async = require('async');
var format = require('util').format;
var libuuid = require('libuuid');

var errors = require('../errors');
var common = require('./vm-common');


var UUID_RE = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
/*JSSTYLED*/
var ALIAS_RE = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
/*JSSTYLED*/
var IP_RE = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
var PW_SUFFIX = /^(.*)_pw$/;

var VALID_VM_BRANDS = [
    'joyent-minimal',
    'joyent',
    'lx',
    'kvm',
    'sngl'
];

var DEFAULT_QUOTA = 10; // GiB
var MIN_SWAP = 256;     // MiB


var VM_FIELDS = [
    {
        name: 'alias',
        mutable: true
    },
    {<commit_msg>ZAPI-576 VMAPI should be more permissive wrt alias validation<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2014, Joyent, Inc.
 */

/*
 * All validation related functions. They mostly apply to CreateVm and UpdateVm
 */


var assert = require('assert');
var restify = require('restify');
var async = require('async');
var format = require('util').format;
var libuuid = require('libuuid');

var errors = require('../errors');
var common = require('./vm-common');


var UUID_RE = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
var ALIAS_RE = /^[a-zA-Z0-9][a-zA-Z0-9\_\.\-]*$/;
/*JSSTYLED*/
var IP_RE = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
var PW_SUFFIX = /^(.*)_pw$/;

var VALID_VM_BRANDS = [
    'joyent-minimal',
    'joyent',
    'lx',
    'kvm',
    'sngl'
];

var DEFAULT_QUOTA = 10; // GiB
var MIN_SWAP = 256;     // MiB


var VM_FIELDS = [
    {
        name: 'alias',
        mutable: true
    },
    {
{'fraction_non_alphanumeric': 0.2435211846976553, 'fraction_numerical': 0.06540518305224187, 'mean_word_length': 2.948051948051948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3066783', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1081, 'n_words': 221}