-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
28 changed files
with
2,015 additions
and
132 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
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
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
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
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,34 @@ | ||
# | ||
# JBZoo Toolbox - Csv-Blueprint. | ||
# | ||
# This file is part of the JBZoo Toolbox project. | ||
# For the full copyright and license information, please view the LICENSE | ||
# file that was distributed with this source code. | ||
# | ||
# @license MIT | ||
# @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
# @see https://github.com/JBZoo/Csv-Blueprint | ||
# | ||
|
||
name: Presets for database columns | ||
description: This schema contains basic rules for database user data. | ||
|
||
columns: | ||
- name: id | ||
description: A unique identifier, usually used to denote a primary key in databases. | ||
example: 12345 | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
is_int: true | ||
num_min: 1 | ||
aggregate_rules: | ||
is_unique: true | ||
sorted: [ asc, numeric ] | ||
|
||
- name: status | ||
description: Status in database | ||
example: active | ||
rules: | ||
not_empty: true | ||
allow_values: [ active, inactive, pending, deleted ] |
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,65 @@ | ||
# | ||
# JBZoo Toolbox - Csv-Blueprint. | ||
# | ||
# This file is part of the JBZoo Toolbox project. | ||
# For the full copyright and license information, please view the LICENSE | ||
# file that was distributed with this source code. | ||
# | ||
# @license MIT | ||
# @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
# @see https://github.com/JBZoo/Csv-Blueprint | ||
# | ||
|
||
name: Complite list of preset features | ||
description: This schema contains all the features of the presets. | ||
|
||
presets: | ||
# The basepath for the preset is `.` (current directory) | ||
# Define alias "db" for schema in `./preset_database.yml` | ||
db: preset_database.yml # Or just `db: preset_database.yml`. It's up to you. | ||
|
||
# For example, you can use a relative path | ||
users: ./../schema-examples/preset_users.yml | ||
|
||
# Or you can use an absolute path | ||
# db-3: /full/path/preset_database.yml | ||
|
||
# Or you can use an absolute path | ||
# db: /full/path/preset_database.yml | ||
|
||
filename_pattern: | ||
preset: users # Take the filename pattern from the preset | ||
|
||
csv: | ||
preset: users # Take the CSV settings from the preset | ||
|
||
columns: | ||
# Use name of column from the preset. "db" is alias. "id" is column `name` in `preset_database.yml` | ||
- preset: 'db/id' | ||
|
||
# Use column index. "db" is alias. "0" is column index in `preset_database.yml` | ||
- preset: 'db/0' | ||
- preset: 'db/0:' | ||
|
||
# Use column index and column name. It useful if column name is not unique. | ||
- preset: 'db/0:id' | ||
|
||
# Override only `rules` from the preset | ||
- name: My column | ||
rules: | ||
preset: 'db/status' | ||
|
||
# Override only `aggregate_rules` from the preset | ||
- name: My column | ||
aggregate_rules: | ||
preset: 'db/0:id' | ||
|
||
# Combo. If you're a risk-taker or have a high level of inner zen. :) | ||
# Creating a column from three other columns. In fact, it will merge all three at once with key replacement. | ||
- name: Crazy combo! | ||
example: ~ | ||
preset: 'users/login' | ||
rules: | ||
preset: 'users/email' | ||
aggregate_rules: | ||
preset: 'db/0' |
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,58 @@ | ||
# | ||
# JBZoo Toolbox - Csv-Blueprint. | ||
# | ||
# This file is part of the JBZoo Toolbox project. | ||
# For the full copyright and license information, please view the LICENSE | ||
# file that was distributed with this source code. | ||
# | ||
# @license MIT | ||
# @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
# @see https://github.com/JBZoo/Csv-Blueprint | ||
# | ||
|
||
name: Schema uses presets and add new columns + specific rules. | ||
description: This schema uses presets. Also, it demonstrates how to override preset values. | ||
|
||
presets: # Include any other schemas and defined for each alias | ||
users: ./preset_users.yml # Include the schema with common user data | ||
db: ./preset_database.yml # Include the schema with basic database columns | ||
|
||
filename_pattern: | ||
preset: users # Take the filename pattern from the preset | ||
|
||
csv: | ||
preset: users # Take the CSV settings from the preset | ||
enclosure: '|' # Overridden value | ||
|
||
columns: | ||
- preset: db/id | ||
- preset: db/status | ||
- preset: users/login | ||
- preset: users/email | ||
- preset: users/full_name | ||
- preset: users/birthday | ||
|
||
- preset: users/password | ||
rules: | ||
length_min: 10 # Overridden value to force a strong password | ||
|
||
- name: user_balance | ||
rules: | ||
preset: users/balance # Take only rules from the preset | ||
|
||
- preset: users/short_description | ||
rules: | ||
length_max: 255 # Overridden value | ||
|
||
- name: phone # Overridden value | ||
preset: users/phone_number | ||
|
||
- name: admin_note | ||
description: Admin note | ||
rules: | ||
not_empty: true | ||
length_min: 1 | ||
length_max: 10 | ||
aggregate_rules: # In practice this will be a rare case, but the opportunity is there. | ||
preset: db/id # Take only aggregate rules from the preset. | ||
is_unique: true # Added new sprcific rule |
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,112 @@ | ||
# | ||
# JBZoo Toolbox - Csv-Blueprint. | ||
# | ||
# This file is part of the JBZoo Toolbox project. | ||
# For the full copyright and license information, please view the LICENSE | ||
# file that was distributed with this source code. | ||
# | ||
# @license MIT | ||
# @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
# @see https://github.com/JBZoo/Csv-Blueprint | ||
# | ||
|
||
name: Common presets for user data | ||
description: This schema contains common presets for user data. It can be used as a base for other schemas. | ||
|
||
filename_pattern: /users-.*\.csv$/i | ||
|
||
csv: | ||
delimiter: ';' | ||
|
||
columns: | ||
- name: login | ||
description: User's login name | ||
example: johndoe | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
is_lowercase: true | ||
is_slug: true | ||
length_min: 3 | ||
length_max: 20 | ||
is_alnum: true | ||
aggregate_rules: | ||
is_unique: true | ||
|
||
- name: password | ||
description: User's password | ||
example: '9RfzE$8NKD' | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
regex: /^[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]{6,}$/ # Safe list of special characters for passwords | ||
contains_none: [ "password", "123456", "qwerty", " " ] | ||
charset: UTF-8 | ||
length_min: 6 | ||
length_max: 20 | ||
|
||
- name: full_name | ||
description: User's full name | ||
example: 'John Doe Smith' | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
charset: UTF-8 | ||
contains: " " | ||
word_count_min: 2 | ||
word_count_max: 8 | ||
is_capitalize: true | ||
aggregate_rules: | ||
is_unique: true | ||
|
||
- name: email | ||
description: User's email address | ||
example: user@example.com | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
is_email: true | ||
is_lowercase: true | ||
aggregate_rules: | ||
is_unique: true | ||
|
||
- name: birthday | ||
description: Validates the user's birthday. | ||
example: '1990-01-01' | ||
rules: | ||
not_empty: true # The birthday field must not be empty. | ||
is_trimmed: true # Trims the value before validation. | ||
date_format: Y-m-d # Checks if the date matches the YYYY-MM-DD format. | ||
is_date: true # Validates if the value is a valid date. | ||
date_age_greater: 0 # Ensures the date is in the past. | ||
date_age_less: 150 # Ensures the user is not older than 150 years. | ||
date_max: now # Ensures the date is not in the future. | ||
|
||
- name: phone_number | ||
description: User's phone number in US | ||
example: '+1 650 253 00 00' | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
starts_with: '+1' | ||
phone: US | ||
|
||
- name: balance | ||
description: User's balance in USD | ||
example: '100.00' | ||
rules: | ||
not_empty: true | ||
is_trimmed: true | ||
is_float: true | ||
num_min: 0.00 | ||
num_max: 1000000000.00 # 1 billion | ||
precision: 2 | ||
|
||
- name: short_description | ||
description: A brief description of the item | ||
example: 'Lorem ipsum dolor sit amet' | ||
rules: | ||
not_empty: true | ||
contains: " " | ||
length_max: 255 | ||
is_trimmed: true |
Oops, something went wrong.