Skip to content

Commit

Permalink
refactor: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomez committed Jan 14, 2024
1 parent 323bafa commit e5d3cf3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/input-form/input-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Input, InputProps } from '@nextui-org/react'

import FormResponse from '@/lib/zod/form-response'

type FormInputProperties = InputProps & {
label: string
export type FormInputProperties = InputProps & {
label?: string
state: FormResponse<unknown>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'

import { LoanBookUseCase } from '@/core/book/application/loan-book-use.case'
import LoanBookUseCase from '@/core/book/application/loan-book-use.case'
import LoanBookRequest from '@/core/book/dto/requests/loan-book.request'
import BooksInMemory from '@/core/book/infrastructure/services/books-in-memory.repository'
import ApplicationError from '@/core/common/domain/errors/application-error'
Expand Down
2 changes: 1 addition & 1 deletion src/core/book/application/loan-book-use.case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BookId from '@/core/common/domain/value-objects/book-id'
import UserId from '@/core/common/domain/value-objects/user-id'
import LoanBookService from '@/core/loan/domain/services/loan-book.service'

export class LoanBookUseCase {
export default class LoanBookUseCase {
constructor(
private readonly books: Books,
private readonly loanBookService: LoanBookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('FullName', () => {
)
})

it('should return a FullNameError for an invalid name', () => {
it('should return a FullNameError for an long name', () => {
// Arrange
const invalidName = 'Jo' // Name length is less than 3
const invalidName = 'A'.repeat(65)

// Act
const result = FullName.create(invalidName)
Expand Down
6 changes: 5 additions & 1 deletion src/core/common/domain/value-objects/fullname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ export default class FullName {
constructor(public readonly value: string) {}

public static create(author: string): Result<FullName, DomainError> {
if (!author || author.length < 3) {
if (!author || author.length === 0) {
return DomainError.cause('El nombre es demasiado corto.')
}

if (author.length > 64) {
return DomainError.cause('El nombre es demasiado largo.')
}

return ok(new FullName(author))
}
}

0 comments on commit e5d3cf3

Please sign in to comment.