Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Micro::Case::Config (enable_attributes_accept = true) #90

Open
serradura opened this issue Sep 9, 2020 · 0 comments
Open

Add new Micro::Case::Config (enable_attributes_accept = true) #90

serradura opened this issue Sep 9, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@serradura
Copy link
Owner

serradura commented Sep 9, 2020

Configurations:

Micro::Case.config do |config|
  config.enable_attributes_accept = true

  config.enable_activemodel_validation = true
end

Attributes changes:

attribute :first_name, accept: String, 
                      default: -> value { value.try(:strip) },
                      validates: { length: { maximum: 30 } }

# ---

attribute :first_name, accept: String, 
                      default: Kind::Try(:strip), # Kind::Try will be available as soon as possible
                      validates: { length: { maximum: 30 } }

The execution order will be:

  1. u-attributes: Fetch the default value
  2. u-attributes: Validate using the accept/reject (options Add Micro::Attributes.with(:accept) u-attributes#8)
  3. u-case: Valide using ActiveModel::Validation if the u-attributes validation was ok.
@serradura serradura added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 9, 2020
@serradura serradura added this to the 4.1.0 milestone Sep 9, 2020
@serradura serradura self-assigned this Sep 9, 2020
@serradura serradura changed the title Add new Micro::Case::Config (enable_attributes_acceptance = true) Add new Micro::Case::Config (enable_attributes_requirements = true) Sep 13, 2020
@serradura serradura changed the title Add new Micro::Case::Config (enable_attributes_requirements = true) Add new Micro::Case::Config (enable_attributes_accept = true) Sep 16, 2020
@serradura serradura modified the milestones: 4.1.0, 4.2.0 Oct 14, 2020
@serradura serradura removed the documentation Improvements or additions to documentation label Oct 14, 2020
@serradura serradura modified the milestones: 4.2.0, 4.x Oct 16, 2020
@serradura serradura modified the milestones: 4.x, Ideas Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant