-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2aa72f6
Showing
15 changed files
with
6,330 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
|
||
env: | ||
browser: true | ||
es2021: true | ||
extends: airbnb-base | ||
overrides: [] | ||
parserOptions: | ||
ecmaVersion: latest | ||
sourceType: module | ||
rules: | ||
import/extensions: | ||
- error | ||
# - ignorePackages | ||
- js: always | ||
no-console: 0 | ||
no-underscore-dangle: [2, {"allow": ["__filename", "__dirname"]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"name": "step1", | ||
"setup": "npm install", | ||
"run": "node --test --test-name-pattern step1", | ||
"input": "", | ||
"output": "", | ||
"comparison": "included", | ||
"timeout": 10, | ||
"points": 1 | ||
}, | ||
{ | ||
"name": "step2", | ||
"setup": "npm install", | ||
"run": "node --test --test-name-pattern step2", | ||
"input": "", | ||
"output": "", | ||
"comparison": "included", | ||
"timeout": 10, | ||
"points": 1 | ||
}, | ||
{ | ||
"name": "step3", | ||
"setup": "npm install", | ||
"run": "node --test --test-name-pattern step3", | ||
"input": "", | ||
"output": "", | ||
"comparison": "included", | ||
"timeout": 10, | ||
"points": 1 | ||
}, | ||
{ | ||
"name": "step4", | ||
"setup": "npm install", | ||
"run": "node --test --test-name-pattern step4", | ||
"input": "", | ||
"output": "", | ||
"comparison": "included", | ||
"timeout": 10, | ||
"points": 1 | ||
}, | ||
{ | ||
"name": "step5", | ||
"setup": "npm install", | ||
"run": "node --test --test-name-pattern step5", | ||
"input": "", | ||
"output": "", | ||
"comparison": "included", | ||
"timeout": 10, | ||
"points": 1 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
|
||
name: GitHub Classroom Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
checks: write | ||
actions: read | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Autograding | ||
runs-on: self-hosted | ||
if: github.actor != 'Bot' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
- uses: education/autograding@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: test-check | ||
|
||
on: | ||
push: | ||
branches: | ||
- source | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
|
||
defaults: | ||
run: | ||
working-directory: app | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: hexlet-college-students/transcrypt-actions@main | ||
with: | ||
PASSWORD: ${{ secrets.TRANSCRYPT_PASSWORD }} | ||
name: decrypting-action | ||
|
||
- run: make install | ||
- run: make lint | ||
- run: make test | ||
|
||
- name: setup git config | ||
run: | | ||
git config user.name "Bot" | ||
git config user.email "<>" | ||
- name: Prepare template | ||
run: | | ||
git checkout --orphan main source | ||
echo '' > src/index.js | ||
echo '' > .gitattributes # disable encryption | ||
git add -A | ||
git commit --no-verify -m "Rebuild template (auto)" | ||
git push -f --no-verify --set-upstream origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node-options=--no-warnings --experimental-vm-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
setup: install | ||
npx simple-git-hooks | ||
|
||
install: | ||
npm ci | ||
|
||
test: | ||
npm test | ||
|
||
lint: | ||
npx eslint . | ||
|
||
lint-fix: | ||
npx eslint . --fix | ||
|
||
update-deps: | ||
npx ncu -u | ||
|
||
test-steps: | ||
node --test --test-name-pattern step1 | ||
node --test --test-name-pattern step2 | ||
node --test --test-name-pattern step3 | ||
node --test --test-name-pattern step4 | ||
node --test --test-name-pattern step5 | ||
|
||
test-step: | ||
node --test --test-name-pattern step$(STEP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Правила и регламент | ||
|
||
- [Экзамен: правила, рекомендации и порядок проведения](https://hexly.notion.site/d9289c18871c44508bc7c7f05a51d94f) | ||
|
||
## Задание | ||
|
||
Ваша задача написать логику валидации с помощью регулярных выражений, отправки формы и перенаправления на другую страницу. Результатом должна являться функция `engine()` экспортированная по умолчанию из файла **src/index.js**. Проверить функции валидации почты и пароля можно, запустив тесты, либо с помощью функции `engine()`. | ||
|
||
## Задача 1 | ||
|
||
Напишите и экспортируйте функцию `validateName()`, которая валидирует строку с условием, что валидным именем считается любая строка с длиной больше 0. Если имя валидно, то функция возвращает пустой объект, иначе возвращается объект с ключом errors, который содержит массив со строкой 'введите имя'. | ||
|
||
```javascript | ||
validateName('[email protected]') // {} | ||
validateName('') // {errors: ['имя не может быть пустым']} | ||
``` | ||
|
||
## Задача 2 | ||
|
||
Напишите и экспортируйте функцию `validateEmail()`, которая email, с условием, что валидной почтой считается любая строка с символом `@` посередине, с любой длиной символов, исключая пробелы до и после нее. Если почта валидна, то функция возвращает пустой объект, иначе возвращается объект с ключом errors, который содержит массив со строкой 'введите валидный email'. | ||
|
||
```javascript | ||
validateEmail('[email protected]') // {} | ||
validateEmail('@gmail.com') // {errors: ['невалидный email']} | ||
validateEmail('g@ и') // {errors: ['невалидный email']} | ||
validateEmail('g@s') // {} | ||
``` | ||
|
||
## Задача 3 | ||
|
||
Форма, данная в файле **index.html**, имеет кнопку `submit` c текстом 'зарегистрироваться'. Ваша задача состоит в том, чтобы реализовать для этой кнопки статус active, когда все поля получили валидные данные. Иначе, если хотя бы одно поле не является валидным, кнопка должна иметь атрибут `disabled`. | ||
|
||
## Задача 4 | ||
|
||
Напишите функцию `app()`, который будет ответственна за запуск и работу приложения. | ||
|
||
Внутри функции напишите код, который реализует для формы контролируемый input, который будет добавлять класс `такой-то` на инпут, если его содержимое валидно. Иначе input должен иметь класс `такой-то`. | ||
|
||
## Задача 5 | ||
|
||
При нажатии кнопки `зарегистрироваться` должен отправляться запрос на сервер с данными формы и в случае успешного ответа вместо формы нужно вывести строку `<p>Пользователь успешно зарегистрирован</p>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { test } from 'node:test'; | ||
import assert from 'assert/strict'; | ||
import { validateEmail, validatePassword } from '../src/index.js'; | ||
|
||
test('step1', () => { | ||
assert.equal(validateEmail('[email protected]'), 'Email валиден'); | ||
assert.equal(validateEmail('[email protected]'), 'Email валиден'); | ||
assert.equal(validateEmail('[email protected]'), 'Email валиден'); | ||
}); | ||
|
||
test('step2', () => { | ||
assert.equal(validateEmail('invalidemail'), 'Ошибка: Неверный формат email'); | ||
assert.equal(validateEmail('[email protected]'), 'Ошибка: Неверный формат email'); | ||
assert.equal(validateEmail('hhhhh @ g m a i l . c o m'), 'Ошибка: Неверный формат email'); | ||
}); | ||
|
||
test('step3', () => { | ||
assert.equal(validatePassword('pass@word1'), 'Пароль валиден'); | ||
assert.equal(validatePassword('pass!word1'), 'Пароль валиден'); | ||
assert.equal(validatePassword('_password'), 'Пароль валиден'); | ||
}); | ||
|
||
test('step4', () => { | ||
assert.equal(validatePassword('password'), 'Ошибка: Пароль должен содержать спец. символы'); | ||
}); | ||
|
||
test('step5', () => { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import engine from './src/index.js'; | ||
|
||
engine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | ||
<title>Регистрация</title> | ||
</head> | ||
<body> | ||
<div class="container mt-5 validationForm"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-6"> | ||
<h2 class="mb-4">Регистрация</h2> | ||
<form id="registrationForm"> | ||
<div class="form-group"> | ||
<label for="inputName">Имя</label> | ||
<input type="text" class="form-control" id="inputName" placeholder="Введите ваше имя" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="inputEmail">Email адрес</label> | ||
<input type="email" class="form-control" id="inputEmail" placeholder="Введите email" required> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Зарегистрироваться</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
<script type="module" src="app.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.