-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add required fields validation logic #250
base: master
Are you sure you want to change the base?
Conversation
This PR exceeds the recommended size of 1000 lines. Check if you are NOT addressing multiple issues with one PR. If is not the case continue the review process. |
631c58f
to
7896998
Compare
This PR exceeds the recommended size of 1000 lines. Check if you are NOT addressing multiple issues with one PR. If is not the case continue the review process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking maybe eox-nelp would need a common validators file for all the project.
Not using different validators for required_fields_validation or pearson_vue or course_experience...
This mainly for the validate_{}
functions...
return re.match(arabic_regex, value) is not None | ||
|
||
|
||
def validate_cp1252(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function already exists.
https://github.com/eduNEXT/eox-nelp/blob/master/eox_nelp/pearson_vue/utils.py#L53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both files are removed in this pr
Returns: | ||
bool: True if valid, False otherwise. | ||
""" | ||
arabic_regex = r'^[\u0600-\u06FF\s]+$' # Unicode range for Arabic characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be imported from here?
https://github.com/nelc/nelp-custom-registration-fields/blob/main/custom_reg_form/forms.py#L26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, basically that is a protected method
Is the suggestion to rename the file ? if so, what are your suggestions |
IMO we could use a Including:
This is with the intention of reusing it in the rest of the folders with apps. |
Done |
This PR exceeds the recommended size of 1000 lines. Check if you are NOT addressing multiple issues with one PR. If is not the case continue the review process. |
7e789ef
to
f5daa81
Compare
This PR exceeds the recommended size of 1000 lines. Check if you are NOT addressing multiple issues with one PR. If is not the case continue the review process. |
Description
This PR adds a method for validating user fields based on the REQUIRED_USER_FIELDS setting.
The validation ensures that each field meets the specified constraints, such as max_length, char_type, format, and optional_values.
Changes Introduced
Implemented validate_required_user_fields, which checks user fields against predefined validation rules.
Added specific validation methods for max_length, char_type, format, and optional_values.
Integrated structured settings to define required fields.
Added unit tests to ensure correct validation behavior.
How to Test
./manage.py lms shell
Expected Outcome
Fields that do not comply with the settings should be flagged as invalid.
The function should return a dictionary containing invalid fields and their respective errors.