Updates the currency validation to allow an optional negative

This commit is contained in:
Trenton Holmes 2024-04-10 06:32:42 -07:00
parent d06faa2fcb
commit c0f13293f7

View File

@ -546,7 +546,7 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer):
except Exception: except Exception:
# If that fails, try to validate as a monetary string # If that fails, try to validate as a monetary string
RegexValidator( RegexValidator(
regex=r"^[A-Z][A-Z][A-Z]\d+(\.\d{2,2})$", regex=r"^[A-Z]{3}-?\d+(\.\d{2,2})$",
message="Must be a two-decimal number with optional currency code e.g. GBP123.45", message="Must be a two-decimal number with optional currency code e.g. GBP123.45",
)(data["value"]) )(data["value"])
elif field.data_type == CustomField.FieldDataType.STRING: elif field.data_type == CustomField.FieldDataType.STRING: