@coveo/bueno
Advanced tools
Comparing version 0.1.0-alpha.35 to 0.1.0-alpha.38
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.1.0-alpha.38](https://bitbucket.org/coveord/ui-kit/compare/v0.1.0-alpha.37...v0.1.0-alpha.38) (2020-11-06) | ||
### Features | ||
* **bueno:** allow RecordValue<string, ArrayValue> ([de086b0](https://bitbucket.org/coveord/ui-kit/commits/de086b07f4f984885510843c969dedec8921f7e9)) | ||
# [0.1.0-alpha.35](https://bitbucket.org/coveord/ui-kit/compare/v0.1.0-alpha.34...v0.1.0-alpha.35) (2020-11-04) | ||
@@ -8,0 +19,0 @@ |
@@ -1,2 +0,2 @@ | ||
class t extends Error{constructor(t){super("The following properties are invalid:"+t.map((t=>"\n"+t))),this.name="SchemaValidationError"}}class e{constructor(t){this.definition=t}validate(e={}){const i={...this.default,...e},n=[];for(const t in this.definition){const e=this.definition[t].validate(i[t]);e&&n.push(`${t}: ${e}`)}if(n.length)throw new t(n);return i}get default(){const t={};for(const e in this.definition){const i=this.definition[e].default;void 0!==i&&(t[e]=i)}return t}}class i{constructor(t={}){this.baseConfig=t}validate(t){return this.baseConfig.required&&r(t)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}required(){return!0===this.baseConfig.required}}function n(t){return void 0===t}function u(t){return null===t}function r(t){return n(t)||u(t)}class a{constructor(t={}){this.config=t,this.value=new i(t)}validate(t){const e=this.value.validate(t);return e||(l(t)?t<this.config.min?`minimum value of ${this.config.min} not respected.`:t>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required()}}function l(t){return n(t)||s(t)}function s(t){return"number"==typeof t}class o{constructor(t={}){this.value=new i(t)}validate(t){const e=this.value.validate(t);return e||(f(t)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required()}}function f(t){return n(t)||c(t)}function c(t){return"boolean"==typeof t}const d={emptyAllowed:!0,url:!1},h=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;class v{constructor(t={}){this.config={...d,...t},this.value=new i(this.config)}validate(t){const e=this.value.validate(t);return e||(n(t)?null:g(t)?this.config.emptyAllowed||t.length?this.config.url&&!h.test(t)?"value is not a valid URL.":null:"value is an empty string.":"value is not a string.")}get default(){return this.value.default}get required(){return this.value.required()}}function g(t){return"[object String]"===Object.prototype.toString.call(t)}class m{constructor(t={}){this.values=t}validate(t){if(!b(t))return"value is not an object";if(Object.keys(t).length>Object.keys(this.values).length)return"value contains unknown keys";for(const[e,i]of Object.entries(this.values))if(i.required&&r(t[e]))return"value does not contain "+e;let e="";for(const[i,n]of Object.entries(t)){const t=new v({required:!0}).validate(i);if(null!==t)return t;let u=null;(c(n)||g(n)||s(n))&&(u=this.values[i].validate(n)),null!==u&&(e+=" "+u)}return""===e?null:e}get default(){}required(){return!1}}function b(t){return void 0!==t&&"object"==typeof t}class p{constructor(t={}){this.config=t,this.value=new i(this.config)}validate(t){if(!r(t)&&!Array.isArray(t))return"value is not an array";const e=this.value.validate(t);if(null!==e)return e;if(r(t))return null;if(void 0!==this.config.max&&t.length>this.config.max)return"value contains more than "+this.config.max;if(void 0!==this.config.min&&t.length<this.config.min)return"value contains less than "+this.config.min;if(void 0!==this.config.each){let e="";return t.forEach((i=>{this.config.each.required&&r(i)&&(e="value is null or undefined: "+t.join(","));const n=this.validatePrimitiveValue(i,this.config.each);null!==n&&(e+=" "+n)})),""===e?null:e}return null}validatePrimitiveValue(t,e){return c(t)||g(t)||s(t)?e.validate(t):"value is not a primitive value"}get default(){}}class q{constructor(t){this.config=t,this.value=new i(t)}validate(t){const e=this.value.validate(t);if(null!==e)return e;if(n(t))return null;return Object.values(this.config.enum).find((e=>e===t))?null:"value is not in enum."}get default(){return this.value.default}}export{p as ArrayValue,o as BooleanValue,q as EnumValue,a as NumberValue,m as RecordValue,e as Schema,t as SchemaValidationError,v as StringValue,i as Value,c as isBoolean,f as isBooleanOrUndefined,u as isNull,r as isNullOrUndefined,s as isNumber,l as isNumberOrUndefined,b as isRecord,g as isString,n as isUndefined}; | ||
class t extends Error{constructor(t){super("The following properties are invalid:"+t.map((t=>"\n"+t))),this.name="SchemaValidationError"}}class e{constructor(t){this.definition=t}validate(e={}){const i={...this.default,...e},n=[];for(const t in this.definition){const e=this.definition[t].validate(i[t]);e&&n.push(`${t}: ${e}`)}if(n.length)throw new t(n);return i}get default(){const t={};for(const e in this.definition){const i=this.definition[e].default;void 0!==i&&(t[e]=i)}return t}}class i{constructor(t={}){this.baseConfig=t}validate(t){return this.baseConfig.required&&u(t)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}required(){return!0===this.baseConfig.required}}function n(t){return void 0===t}function r(t){return null===t}function u(t){return n(t)||r(t)}class a{constructor(t={}){this.config=t,this.value=new i(t)}validate(t){const e=this.value.validate(t);return e||(l(t)?t<this.config.min?`minimum value of ${this.config.min} not respected.`:t>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required()}}function l(t){return n(t)||s(t)}function s(t){return"number"==typeof t}class o{constructor(t={}){this.value=new i(t)}validate(t){const e=this.value.validate(t);return e||(f(t)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required()}}function f(t){return n(t)||c(t)}function c(t){return"boolean"==typeof t}const d={emptyAllowed:!0,url:!1},h=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;class v{constructor(t={}){this.config={...d,...t},this.value=new i(this.config)}validate(t){const e=this.value.validate(t);return e||(n(t)?null:g(t)?this.config.emptyAllowed||t.length?this.config.url&&!h.test(t)?"value is not a valid URL.":null:"value is an empty string.":"value is not a string.")}get default(){return this.value.default}get required(){return this.value.required()}}function g(t){return"[object String]"===Object.prototype.toString.call(t)}class m{constructor(t={}){this.values=t}validate(t){if(!b(t))return"value is not an object";if(Object.keys(t).length>Object.keys(this.values).length)return"value contains unknown keys";for(const[e,i]of Object.entries(this.values))if(i.required&&u(t[e]))return"value does not contain "+e;let e="";for(const[i,n]of Object.entries(t)){const t=new v({required:!0}).validate(i);if(null!==t)return t;let r=null;(c(n)||g(n)||s(n)||q(n))&&(r=this.values[i].validate(n)),null!==r&&(e+=" "+r)}return""===e?null:e}get default(){}required(){return!1}}function b(t){return void 0!==t&&"object"==typeof t}class p{constructor(t={}){this.config=t,this.value=new i(this.config)}validate(t){if(!u(t)&&!Array.isArray(t))return"value is not an array";const e=this.value.validate(t);if(null!==e)return e;if(u(t))return null;if(void 0!==this.config.max&&t.length>this.config.max)return"value contains more than "+this.config.max;if(void 0!==this.config.min&&t.length<this.config.min)return"value contains less than "+this.config.min;if(void 0!==this.config.each){let e="";return t.forEach((i=>{this.config.each.required&&u(i)&&(e="value is null or undefined: "+t.join(","));const n=this.validatePrimitiveValue(i,this.config.each);null!==n&&(e+=" "+n)})),""===e?null:e}return null}validatePrimitiveValue(t,e){return c(t)||g(t)||s(t)||b(t)?e.validate(t):"value is not a primitive value"}get default(){}get required(){return this.value.required()}}function q(t){return Array.isArray(t)}class y{constructor(t){this.config=t,this.value=new i(t)}validate(t){const e=this.value.validate(t);if(null!==e)return e;if(n(t))return null;return Object.values(this.config.enum).find((e=>e===t))?null:"value is not in enum."}get default(){return this.value.default}}export{p as ArrayValue,o as BooleanValue,y as EnumValue,a as NumberValue,m as RecordValue,e as Schema,t as SchemaValidationError,v as StringValue,i as Value,q as isArray,c as isBoolean,f as isBooleanOrUndefined,r as isNull,u as isNullOrUndefined,s as isNumber,l as isNumberOrUndefined,b as isRecord,g as isString,n as isUndefined}; | ||
//# sourceMappingURL=bueno.esm.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Bueno={})}(this,(function(e){"use strict";class t extends Error{constructor(e){super("The following properties are invalid:"+e.map((e=>"\n"+e))),this.name="SchemaValidationError"}}class n{constructor(e={}){this.baseConfig=e}validate(e){return this.baseConfig.required&&r(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}required(){return!0===this.baseConfig.required}}function i(e){return void 0===e}function u(e){return null===e}function r(e){return i(e)||u(e)}function a(e){return i(e)||l(e)}function l(e){return"number"==typeof e}function s(e){return i(e)||o(e)}function o(e){return"boolean"==typeof e}const f={emptyAllowed:!0,url:!1},d=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;class c{constructor(e={}){this.config={...f,...e},this.value=new n(this.config)}validate(e){const t=this.value.validate(e);return t||(i(e)?null:h(e)?this.config.emptyAllowed||e.length?this.config.url&&!d.test(e)?"value is not a valid URL.":null:"value is an empty string.":"value is not a string.")}get default(){return this.value.default}get required(){return this.value.required()}}function h(e){return"[object String]"===Object.prototype.toString.call(e)}function v(e){return void 0!==e&&"object"==typeof e}e.ArrayValue=class{constructor(e={}){this.config=e,this.value=new n(this.config)}validate(e){if(!r(e)&&!Array.isArray(e))return"value is not an array";const t=this.value.validate(e);if(null!==t)return t;if(r(e))return null;if(void 0!==this.config.max&&e.length>this.config.max)return"value contains more than "+this.config.max;if(void 0!==this.config.min&&e.length<this.config.min)return"value contains less than "+this.config.min;if(void 0!==this.config.each){let t="";return e.forEach((n=>{this.config.each.required&&r(n)&&(t="value is null or undefined: "+e.join(","));const i=this.validatePrimitiveValue(n,this.config.each);null!==i&&(t+=" "+i)})),""===t?null:t}return null}validatePrimitiveValue(e,t){return o(e)||h(e)||l(e)?t.validate(e):"value is not a primitive value"}get default(){}},e.BooleanValue=class{constructor(e={}){this.value=new n(e)}validate(e){const t=this.value.validate(e);return t||(s(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required()}},e.EnumValue=class{constructor(e){this.config=e,this.value=new n(e)}validate(e){const t=this.value.validate(e);if(null!==t)return t;if(i(e))return null;return Object.values(this.config.enum).find((t=>t===e))?null:"value is not in enum."}get default(){return this.value.default}},e.NumberValue=class{constructor(e={}){this.config=e,this.value=new n(e)}validate(e){const t=this.value.validate(e);return t||(a(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required()}},e.RecordValue=class{constructor(e={}){this.values=e}validate(e){if(!v(e))return"value is not an object";if(Object.keys(e).length>Object.keys(this.values).length)return"value contains unknown keys";for(const[t,n]of Object.entries(this.values))if(n.required&&r(e[t]))return"value does not contain "+t;let t="";for(const[n,i]of Object.entries(e)){const e=new c({required:!0}).validate(n);if(null!==e)return e;let u=null;(o(i)||h(i)||l(i))&&(u=this.values[n].validate(i)),null!==u&&(t+=" "+u)}return""===t?null:t}get default(){}required(){return!1}},e.Schema=class{constructor(e){this.definition=e}validate(e={}){const n={...this.default,...e},i=[];for(const e in this.definition){const t=this.definition[e].validate(n[e]);t&&i.push(`${e}: ${t}`)}if(i.length)throw new t(i);return n}get default(){const e={};for(const t in this.definition){const n=this.definition[t].default;void 0!==n&&(e[t]=n)}return e}},e.SchemaValidationError=t,e.StringValue=c,e.Value=n,e.isBoolean=o,e.isBooleanOrUndefined=s,e.isNull=u,e.isNullOrUndefined=r,e.isNumber=l,e.isNumberOrUndefined=a,e.isRecord=v,e.isString=h,e.isUndefined=i,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Bueno={})}(this,(function(e){"use strict";class t extends Error{constructor(e){super("The following properties are invalid:"+e.map((e=>"\n"+e))),this.name="SchemaValidationError"}}class i{constructor(e={}){this.baseConfig=e}validate(e){return this.baseConfig.required&&u(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}required(){return!0===this.baseConfig.required}}function n(e){return void 0===e}function r(e){return null===e}function u(e){return n(e)||r(e)}function a(e){return n(e)||l(e)}function l(e){return"number"==typeof e}function s(e){return n(e)||o(e)}function o(e){return"boolean"==typeof e}const f={emptyAllowed:!0,url:!1},d=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;class c{constructor(e={}){this.config={...f,...e},this.value=new i(this.config)}validate(e){const t=this.value.validate(e);return t||(n(e)?null:h(e)?this.config.emptyAllowed||e.length?this.config.url&&!d.test(e)?"value is not a valid URL.":null:"value is an empty string.":"value is not a string.")}get default(){return this.value.default}get required(){return this.value.required()}}function h(e){return"[object String]"===Object.prototype.toString.call(e)}function v(e){return void 0!==e&&"object"==typeof e}function g(e){return Array.isArray(e)}e.ArrayValue=class{constructor(e={}){this.config=e,this.value=new i(this.config)}validate(e){if(!u(e)&&!Array.isArray(e))return"value is not an array";const t=this.value.validate(e);if(null!==t)return t;if(u(e))return null;if(void 0!==this.config.max&&e.length>this.config.max)return"value contains more than "+this.config.max;if(void 0!==this.config.min&&e.length<this.config.min)return"value contains less than "+this.config.min;if(void 0!==this.config.each){let t="";return e.forEach((i=>{this.config.each.required&&u(i)&&(t="value is null or undefined: "+e.join(","));const n=this.validatePrimitiveValue(i,this.config.each);null!==n&&(t+=" "+n)})),""===t?null:t}return null}validatePrimitiveValue(e,t){return o(e)||h(e)||l(e)||v(e)?t.validate(e):"value is not a primitive value"}get default(){}get required(){return this.value.required()}},e.BooleanValue=class{constructor(e={}){this.value=new i(e)}validate(e){const t=this.value.validate(e);return t||(s(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required()}},e.EnumValue=class{constructor(e){this.config=e,this.value=new i(e)}validate(e){const t=this.value.validate(e);if(null!==t)return t;if(n(e))return null;return Object.values(this.config.enum).find((t=>t===e))?null:"value is not in enum."}get default(){return this.value.default}},e.NumberValue=class{constructor(e={}){this.config=e,this.value=new i(e)}validate(e){const t=this.value.validate(e);return t||(a(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required()}},e.RecordValue=class{constructor(e={}){this.values=e}validate(e){if(!v(e))return"value is not an object";if(Object.keys(e).length>Object.keys(this.values).length)return"value contains unknown keys";for(const[t,i]of Object.entries(this.values))if(i.required&&u(e[t]))return"value does not contain "+t;let t="";for(const[i,n]of Object.entries(e)){const e=new c({required:!0}).validate(i);if(null!==e)return e;let r=null;(o(n)||h(n)||l(n)||g(n))&&(r=this.values[i].validate(n)),null!==r&&(t+=" "+r)}return""===t?null:t}get default(){}required(){return!1}},e.Schema=class{constructor(e){this.definition=e}validate(e={}){const i={...this.default,...e},n=[];for(const e in this.definition){const t=this.definition[e].validate(i[e]);t&&n.push(`${e}: ${t}`)}if(n.length)throw new t(n);return i}get default(){const e={};for(const t in this.definition){const i=this.definition[t].default;void 0!==i&&(e[t]=i)}return e}},e.SchemaValidationError=t,e.StringValue=c,e.Value=i,e.isArray=g,e.isBoolean=o,e.isBooleanOrUndefined=s,e.isNull=r,e.isNullOrUndefined=u,e.isNumber=l,e.isNumberOrUndefined=a,e.isRecord=v,e.isString=h,e.isUndefined=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=bueno.js.map |
@@ -6,4 +6,3 @@ export * from './schema'; | ||
export * from './values/string-value'; | ||
export * from './values/record-value'; | ||
export * from './values/array-value'; | ||
export * from './values/complex-value'; | ||
export * from './values/enum-value'; |
import { SchemaValue } from '../schema'; | ||
export declare type PrimitivesValues = boolean | number | string | undefined | null; | ||
export declare type PrimitivesValues = boolean | number | string | object | undefined | null; | ||
export interface ValueConfig<T> { | ||
@@ -4,0 +4,0 @@ default?: (() => T) | T; |
@@ -206,2 +206,5 @@ class SchemaValidationError extends Error { | ||
} | ||
else if (isArray(v)) { | ||
invalidValue = this.values[k].validate(v); | ||
} | ||
if (invalidValue !== null) { | ||
@@ -223,3 +226,2 @@ out += ' ' + invalidValue; | ||
} | ||
class ArrayValue { | ||
@@ -272,2 +274,5 @@ constructor(config = {}) { | ||
} | ||
else if (isRecord(v)) { | ||
return validator.validate(v); | ||
} | ||
return 'value is not a primitive value'; | ||
@@ -278,3 +283,9 @@ } | ||
} | ||
get required() { | ||
return this.value.required(); | ||
} | ||
} | ||
function isArray(value) { | ||
return Array.isArray(value); | ||
} | ||
@@ -305,2 +316,2 @@ class EnumValue { | ||
export { ArrayValue, BooleanValue, EnumValue, NumberValue, RecordValue, Schema, SchemaValidationError, StringValue, Value, isBoolean, isBooleanOrUndefined, isNull, isNullOrUndefined, isNumber, isNumberOrUndefined, isRecord, isString, isUndefined }; | ||
export { ArrayValue, BooleanValue, EnumValue, NumberValue, RecordValue, Schema, SchemaValidationError, StringValue, Value, isArray, isBoolean, isBooleanOrUndefined, isNull, isNullOrUndefined, isNumber, isNumberOrUndefined, isRecord, isString, isUndefined }; |
@@ -210,2 +210,5 @@ 'use strict'; | ||
} | ||
else if (isArray(v)) { | ||
invalidValue = this.values[k].validate(v); | ||
} | ||
if (invalidValue !== null) { | ||
@@ -227,3 +230,2 @@ out += ' ' + invalidValue; | ||
} | ||
class ArrayValue { | ||
@@ -276,2 +278,5 @@ constructor(config = {}) { | ||
} | ||
else if (isRecord(v)) { | ||
return validator.validate(v); | ||
} | ||
return 'value is not a primitive value'; | ||
@@ -282,3 +287,9 @@ } | ||
} | ||
get required() { | ||
return this.value.required(); | ||
} | ||
} | ||
function isArray(value) { | ||
return Array.isArray(value); | ||
} | ||
@@ -318,2 +329,3 @@ class EnumValue { | ||
exports.Value = Value; | ||
exports.isArray = isArray; | ||
exports.isBoolean = isBoolean; | ||
@@ -320,0 +332,0 @@ exports.isBooleanOrUndefined = isBooleanOrUndefined; |
@@ -6,4 +6,3 @@ export * from './schema'; | ||
export * from './values/string-value'; | ||
export * from './values/record-value'; | ||
export * from './values/array-value'; | ||
export * from './values/complex-value'; | ||
export * from './values/enum-value'; |
import { SchemaValue } from '../schema'; | ||
export declare type PrimitivesValues = boolean | number | string | undefined | null; | ||
export declare type PrimitivesValues = boolean | number | string | object | undefined | null; | ||
export interface ValueConfig<T> { | ||
@@ -4,0 +4,0 @@ default?: (() => T) | T; |
@@ -12,3 +12,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "0.1.0-alpha.35", | ||
"version": "0.1.0-alpha.38", | ||
"files": [ | ||
@@ -15,0 +15,0 @@ "dist/" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90940
949
40