diff --git a/docs/cloning.md b/docs/cloning.md index 6a81cb9..52256a6 100644 --- a/docs/cloning.md +++ b/docs/cloning.md @@ -73,6 +73,6 @@ const clonedUser = user.clone( // Error: Invalid Attributes // details: [ -// { message: '"name" is required', path: 'name' } +// { message: '"name" is required', path: ['name'] } // ] ``` diff --git a/docs/strict-mode.md b/docs/strict-mode.md index addc219..701f32e 100644 --- a/docs/strict-mode.md +++ b/docs/strict-mode.md @@ -18,8 +18,8 @@ const user = User.buildStrict({ // Error: Invalid Attributes // details: [ -// { message: '"name" is required', path: 'name' }, -// { message: '"age" must be a number', path: 'age' } +// { message: '"name" is required', path: ['name'] }, +// { message: '"age" must be a number', path: ['age'] } // ] ``` @@ -59,8 +59,8 @@ const book = Book.buildStrict({ // InvalidBookError: Wait, this book is not right // code: 'INVALID_BOOK' -// details: [ -// { message: '"name" is required', path: 'name' }, -// { message: '"year" must be a number', path: 'year' } +// errors: [ +// { message: '"name" is required', path: ['name'] }, +// { message: '"year" must be a number', path: ['year'] } // ] ``` diff --git a/docs/validation/README.md b/docs/validation/README.md index f7b1918..003ab00 100644 --- a/docs/validation/README.md +++ b/docs/validation/README.md @@ -25,8 +25,8 @@ const { valid, errors } = user.validate(); valid; // false errors; /* [ - { message: '"name" length must be at least 10 characters long', path: 'name' }, - { message: '"age" is required', path: 'age' } + { message: '"name" length must be at least 10 characters long', path: ['name'] }, + { message: '"age" is required', path: ['age'] } ] */ diff --git a/docs/validation/attribute-reference.md b/docs/validation/attribute-reference.md index e7bd5d2..c8d9161 100644 --- a/docs/validation/attribute-reference.md +++ b/docs/validation/attribute-reference.md @@ -8,14 +8,14 @@ const User = attributes({ password: String, passwordConfirmation: { type: String, - equal: { attr: 'password' } - } -})(class User { }); + equal: { attr: 'password' }, + }, +})(class User {}); const user = new User({ name: 'Gandalf', password: 'safestpasswordever', - passwordConfirmation: 'notthatsafetho' + passwordConfirmation: 'notthatsafetho', }); const { valid, errors } = user.validate(); @@ -24,9 +24,8 @@ valid; // false errors; /* [ { message: '"passwordConfirmation" must be one of [ref:password]', - path: 'passwordConfirmation' + path: ['passwordConfirmation'] } ] */ - ``` diff --git a/docs/validation/nested-validations.md b/docs/validation/nested-validations.md index 01d0607..9d45ae0 100644 --- a/docs/validation/nested-validations.md +++ b/docs/validation/nested-validations.md @@ -6,26 +6,26 @@ Structure will validate nested values, including array items validations and nes const Book = attributes({ name: { type: String, - required: true - } -})(class Book { }); + required: true, + }, +})(class Book {}); const User = attributes({ initials: { type: String, - minLength: 2 + minLength: 2, }, favoriteBook: Book, books: { type: Array, - itemType: Book - } -})(class User { }); + itemType: Book, + }, +})(class User {}); const user = new User({ initials: 'A', favoriteBook: new Book(), - books: [new Book()] + books: [new Book()], }); const { valid, errors } = user.validate(); @@ -33,9 +33,9 @@ const { valid, errors } = user.validate(); valid; // false errors; /* [ - { message: '"initials" length must be at least 2 characters long', path: 'initials' }, - { message: '"name" is required', path: 'favoriteBook.name' }, - { message: '"name" is required', path: 'books.0.name' } + { message: '"initials" length must be at least 2 characters long', path: ['initials'] }, + { message: '"favoriteBook.name" is required', path: ['favoriteBook', 'name'] }, + { message: '"books[0].name" is required', path: ['books', 0, 'name'] } ] */ ``` diff --git a/docs/validation/validate-raw-data.md b/docs/validation/validate-raw-data.md index 53f5313..e51b6a9 100644 --- a/docs/validation/validate-raw-data.md +++ b/docs/validation/validate-raw-data.md @@ -6,17 +6,17 @@ In addition to the _instance_ `validate()` method, Structure also adds a _static const User = attributes({ name: { type: String, - minLength: 10 + minLength: 10, }, age: { type: Number, - required: true - } -})(class User { }); + required: true, + }, +})(class User {}); // Using a raw object const rawData = { - name: 'John' + name: 'John', }; const { valid, errors } = User.validate(rawData); @@ -24,14 +24,14 @@ const { valid, errors } = User.validate(rawData); valid; // false errors; /* [ - { message: '"name" length must be at least 10 characters long', path: 'name' }, - { message: '"age" is required', path: 'age' } + { message: '"name" length must be at least 10 characters long', path: ['name'] }, + { message: '"age" is required', path: ['age'] } ] */ // Using a structure instance const user = new User({ - name: 'Some long name' + name: 'Some long name', }); const validation = User.validate(user); @@ -39,7 +39,7 @@ const validation = User.validate(user); validation.valid; // false validation.errors; /* [ - { message: '"age" is required', path: 'age' } + { message: '"age" is required', path: ['age'] } ] */ ```