Skip to content

Commit

Permalink
remove old validation
Browse files Browse the repository at this point in the history
  • Loading branch information
noah-art3mis committed Jun 29, 2024
1 parent 112a1dc commit d5078c6
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { Book } from './types.ts';

export function validateData(data: Book) {
isBook(data);
// arePagesUnique(data);
// endsWithPunctuation(data);
// notTooLong(data);
}

function isBook(data: Book) {
Expand All @@ -28,53 +25,3 @@ function isBook(data: Book) {
console.log(message);
}
}

function arePagesUnique(data: Book) {
const pageNumbers = new Set<string>();
for (const page of data.pages) {
if (pageNumbers.has(page.number)) {
const message = `Page number ${page.number} is not unique`;
console.log(message);
}
pageNumbers.add(page.number);
}
}

function endsWithPunctuation(data: Book) {
for (const page of data.pages) {
for (const plate of page.content) {
if (plate.endsWith('.')) {
continue;
}

if (plate.endsWith('?')) {
continue;
}

if (plate.endsWith('!')) {
continue;
}

if (plate.endsWith('"')) {
continue;
}

if (plate.endsWith("'")) {
continue;
}

const message = `${page.number} should end with punctuation`;
console.log(message);
}
}
}

function notTooLong(data: Book) {
for (const page of data.pages) {
if (page.content.length > 10) {
const message = `${page.number} has more than 10 sentences`;
alert(message);
console.log(message);
}
}
}

0 comments on commit d5078c6

Please sign in to comment.