Skip to content

Commit

Permalink
change fix1
Browse files Browse the repository at this point in the history
  • Loading branch information
gpiento committed May 23, 2024
1 parent 418cbaf commit b8cd2bf
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 115 deletions.
File renamed without changes.
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.DEFAULT_GOAL := build-run
.PHONY: build app

setup:
make -C app setup

clean:
make -C app clean

Expand All @@ -13,12 +10,9 @@ build:
install:
make -C app install

run-dist: install
run-dist:
make -C app run-dist

run: install
make -C app run

test:
make -C app test

Expand All @@ -31,4 +25,4 @@ lint:
check-deps:
make -C app check-deps

build-run: build install run-dist
build-run: run-dist
96 changes: 93 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,98 @@
## Data Validator

## Валидатор данных
[![hexlet-check](https://github.com/gpiento/java-project-78/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/gpiento/java-project-78/actions/workflows/hexlet-check.yml)
[![GitHub Workflow Status](https://github.com//gpiento/java-project-78/actions/workflows/github-check.yml/badge.svg)](https://github.com/gpiento/java-project-78/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/5409c5fc72a5aacbfc38/maintainability)](https://codeclimate.com/github/gpiento/java-project-78/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/5409c5fc72a5aacbfc38/test_coverage)](https://codeclimate.com/github/gpiento/java-project-78/test_coverage)
---
Валидатор данных – библиотека, с помощью которой можно проверять корректность любых данных. Подобных библиотек множество в каждом языке, так как практически все программы работают с внешними данными, которые нужно проверять на корректность. В первую очередь речь идет про данные форм заполняемых пользователями.

A data validator is a library that can be used to check the correctness of any data. There are many such libraries in every language, because almost all programs work with external data that need to be checked for correctness. First of all, we are talking about form data filled in by users. The yup library is taken as a basis for the project.

### Valid data types:
- String
- Integer
- Map

### Example of using strings:
```java
import hexlet.code.Validator;
import hexlet.code.schemas.StringSchema;

var v = new Validator();

var schema = v.string();

schema.isValid(""); // true
schema.isValid(null); // true

schema.required();

schema.isValid(null); // false
schema.isValid(""); // false
schema.isValid("what does the fox say"); // true
schema.isValid("hexlet"); // true

schema.contains("wh").isValid("what does the fox say"); // true
schema.contains("what").isValid("what does the fox say"); // true
schema.contains("whatthe").isValid("what does the fox say"); // false

schema.isValid("what does the fox say"); // false

var schema1 = v.string();
schema1.minLength(10).minLength(4).isValid("Hexlet"); // true
```

### Example of using integers:
```java
import hexlet.code.Validator;
import hexlet.code.schemas.NumberSchema;

var v = new Validator();

var schema = v.number();

schema.isValid(5); // true

schema.isValid(null); // true
schema.positive().isValid(null); // true

schema.required();

schema.isValid(null); // false
schema.isValid(10); // true

schema.isValid(-10); // false
schema.isValid(0); // false

schema.range(5, 10);

schema.isValid(5); // true
schema.isValid(10); // true
schema.isValid(4); // false
schema.isValid(11); // false
```

### Example of using maps:
```java
import hexlet.code.Validator;
import hexlet.code.schemas.MapSchema;

var v = new Validator();

var schema = v.map();

schema.isValid(null); // true

schema.required();

schema.isValid(null); // false
schema.isValid(new HashMap<>()); // true
var data = new HashMap<String, String>();
data.put("key1", "value1");
schema.isValid(data); // true

schema.sizeof(2);

schema.isValid(data); // false
data.put("key2", "value2");
schema.isValid(data); // true
```
84 changes: 0 additions & 84 deletions app/.gitignore

This file was deleted.

8 changes: 1 addition & 7 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.DEFAULT_GOAL := build-run
.PHONY: build app

setup:
./gradlew wrapper --gradle-version 8.6

clean:
./gradlew clean

Expand All @@ -16,9 +13,6 @@ install:
run-dist: install
@./build/install/app/bin/app

run: install
@./build/install/app/bin/app

test:
./gradlew test

Expand All @@ -31,4 +25,4 @@ lint:
check-deps:
./gradlew dependencyUpdates -Drevision=release

build-run: build install run-dist
build-run: run-dist
19 changes: 6 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

plugins {
id 'com.github.ben-manes.versions' version '0.51.0'
id 'java'
id 'checkstyle'
id 'jacoco'
// https://plugins.gradle.org/plugin/com.adarshr.test-logger
id 'com.adarshr.test-logger' version '4.0.0'
}

Expand All @@ -19,17 +19,11 @@ repositories {
}

dependencies {
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0-M1'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
// https://mvnrepository.com/artifact/org.junit/junit-bom
testImplementation platform('org.junit:junit-bom:5.11.0-M1')
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0-M1'
// https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
// https://mvnrepository.com/artifact/commons-io/commons-io
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0-M2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.0-M2'
testImplementation platform('org.junit:junit-bom:5.11.0-M2')
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0-M2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0-M2'
implementation 'commons-io:commons-io:2.16.1'
}

Expand All @@ -49,7 +43,6 @@ jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required = true
csv.required = false
}
}

Expand Down

0 comments on commit b8cd2bf

Please sign in to comment.