Skip to content

Commit

Permalink
Move types into their own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed May 14, 2017
1 parent 78843fa commit 0464639
Show file tree
Hide file tree
Showing 27 changed files with 69 additions and 69 deletions.
14 changes: 7 additions & 7 deletions lib/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ const Ref = require('./ref');

const internals = {
any: null,
date: require('./date'),
string: require('./string'),
number: require('./number'),
boolean: require('./boolean'),
date: require('./types/date'),
string: require('./types/string'),
number: require('./types/number'),
boolean: require('./types/boolean'),
alt: null,
object: null
};


exports.schema = function (config) {

internals.any = internals.any || new (require('./any'))();
internals.alt = internals.alt || require('./alternatives');
internals.object = internals.object || require('./object');
internals.any = internals.any || new (require('./types/any'))();
internals.alt = internals.alt || require('./types/alternatives');
internals.object = internals.object || require('./types/object');

if (config !== undefined && config !== null && typeof config === 'object') {

Expand Down
20 changes: 10 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
// Load modules

const Hoek = require('hoek');
const Any = require('./any');
const Any = require('./types/any');
const Cast = require('./cast');
const Errors = require('./errors');
const Lazy = require('./lazy');
const Lazy = require('./types/lazy');
const Ref = require('./ref');


// Declare internals

const internals = {
alternatives: require('./alternatives'),
array: require('./array'),
boolean: require('./boolean'),
binary: require('./binary'),
date: require('./date'),
number: require('./number'),
object: require('./object'),
string: require('./string')
alternatives: require('./types/alternatives'),
array: require('./types/array'),
boolean: require('./types/boolean'),
binary: require('./types/binary'),
date: require('./types/date'),
number: require('./types/number'),
object: require('./types/object'),
string: require('./types/string')
};


Expand Down
6 changes: 3 additions & 3 deletions lib/alternatives.js → lib/types/alternatives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// Load modules

const Hoek = require('hoek');
const Any = require('./any');
const Cast = require('./cast');
const Ref = require('./ref');
const Any = require('../any');
const Cast = require('../../cast');
const Ref = require('../../ref');


// Declare internals
Expand Down
12 changes: 6 additions & 6 deletions lib/any.js → lib/types/any/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
// Load modules

const Hoek = require('hoek');
const Ref = require('./ref');
const Errors = require('./errors');
const Ref = require('../../ref');
const Errors = require('../../errors');
let Alternatives = null; // Delay-loaded to prevent circular dependencies
let Cast = null;


// Declare internals

const internals = {
Set: require('./set')
Set: require('../../set')
};


Expand All @@ -35,7 +35,7 @@ module.exports = internals.Any = class {

constructor() {

Cast = Cast || require('./cast');
Cast = Cast || require('../../cast');

this.isJoi = true;
this._type = 'any';
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = internals.Any = class {

checkOptions(options) {

const Schemas = require('./schemas');
const Schemas = require('../../schemas');
const result = Schemas.options.validate(options);
if (result.error) {
throw new Error(result.error.details[0].message);
Expand Down Expand Up @@ -381,7 +381,7 @@ module.exports = internals.Any = class {
const then = options.hasOwnProperty('then') ? this.concat(Cast.schema(options.then)) : undefined;
const otherwise = options.hasOwnProperty('otherwise') ? this.concat(Cast.schema(options.otherwise)) : undefined;

Alternatives = Alternatives || require('./alternatives');
Alternatives = Alternatives || require('../alternatives');
const obj = Alternatives.when(ref, { is: options.is, then, otherwise });
obj._flags.presence = 'ignore';
obj._baseType = this;
Expand Down
4 changes: 2 additions & 2 deletions lib/array.js → lib/types/array/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// Load modules

const Any = require('./any');
const Cast = require('./cast');
const Any = require('../any');
const Cast = require('../../cast');
const Hoek = require('hoek');


Expand Down
2 changes: 1 addition & 1 deletion lib/binary.js → lib/types/binary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Load modules

const Any = require('./any');
const Any = require('../any');
const Hoek = require('hoek');


Expand Down
4 changes: 2 additions & 2 deletions lib/boolean.js → lib/types/boolean/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

// Load modules

const Any = require('./any');
const Any = require('../any');
const Hoek = require('hoek');


// Declare internals

const internals = {
Set: require('./set')
Set: require('../../set')
};


Expand Down
4 changes: 2 additions & 2 deletions lib/date.js → lib/types/date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// Load modules

const Any = require('./any');
const Ref = require('./ref');
const Any = require('../any');
const Ref = require('../../ref');
const Hoek = require('hoek');


Expand Down
2 changes: 1 addition & 1 deletion lib/lazy.js → lib/types/lazy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Load modules

const Any = require('./any');
const Any = require('../any');
const Hoek = require('hoek');


Expand Down
4 changes: 2 additions & 2 deletions lib/number.js → lib/types/number/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// Load modules

const Any = require('./any');
const Ref = require('./ref');
const Any = require('../any');
const Ref = require('../../ref');
const Hoek = require('hoek');


Expand Down
8 changes: 4 additions & 4 deletions lib/object.js → lib/types/object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

const Hoek = require('hoek');
const Topo = require('topo');
const Any = require('./any');
const Errors = require('./errors');
const Cast = require('./cast');
const Ref = require('./ref');
const Any = require('../any');
const Errors = require('../../errors');
const Cast = require('../../cast');
const Ref = require('../../ref');


// Declare internals
Expand Down
10 changes: 5 additions & 5 deletions lib/string.js → lib/types/string/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
const Net = require('net');
const Hoek = require('hoek');
const Isemail = require('isemail');
const Any = require('./any');
const Ref = require('./ref');
const JoiDate = require('./date');
const Uri = require('./string/uri');
const Ip = require('./string/ip');
const Any = require('../any');
const Ref = require('../../ref');
const JoiDate = require('../date');
const Uri = require('./uri');
const Ip = require('./ip');

// Declare internals

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,7 @@ describe('Joi', () => {
name: 'myType'
});

const Any = require('../lib/any');
const Any = require('../lib/types/any');
expect(customJoi).to.be.an.instanceof(Any);
done();
});
Expand Down
4 changes: 2 additions & 2 deletions test/alternatives.js → test/types/alternatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('..');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/any.js → test/types/any.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/array.js → test/types/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/binary.js → test/types/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/boolean.js → test/types/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/date.js → test/types/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/function.js → test/types/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Code = require('code');
const Lab = require('lab');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
6 changes: 3 additions & 3 deletions test/lazy.js → test/types/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Lazy = require('../lib/lazy');
const Helper = require('./helper');
const Joi = require('../..');
const Lazy = require('../../lib/types/lazy/index');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/number.js → test/types/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/object.js → test/types/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down
4 changes: 2 additions & 2 deletions test/string.js → test/types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const Lab = require('lab');
const Code = require('code');
const Joi = require('../lib');
const Helper = require('./helper');
const Joi = require('../..');
const Helper = require('../helper');


// Declare internals
Expand Down

0 comments on commit 0464639

Please sign in to comment.